Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:24280 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 89751 invoked by uid 1010); 6 Jul 2006 00:43:42 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 89735 invoked from network); 6 Jul 2006 00:43:42 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 6 Jul 2006 00:43:42 -0000 X-PHP-List-Original-Sender: helly@php.net X-Host-Fingerprint: 81.169.182.136 ajaxatwork.net Linux 2.4/2.6 Received: from ([81.169.182.136:33262] helo=strato.aixcept.de) by pb1.pair.com (ecelerity 2.1.1.3 r(11751M)) with ESMTP id 0A/6E-16663-CBC5CA44 for ; Wed, 05 Jul 2006 20:43:41 -0400 Received: from baumbart.mbo (dslb-084-063-002-183.pools.arcor-ip.net [84.63.2.183]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by strato.aixcept.de (Postfix) with ESMTP id 6B1D435C1F4; Thu, 6 Jul 2006 02:43:37 +0200 (CEST) Date: Thu, 6 Jul 2006 02:43:36 +0200 Reply-To: Marcus Boerger X-Priority: 3 (Normal) Message-ID: <572951316.20060706024336@marcus-boerger.de> To: Sara Golemon Cc: internals@lists.php.net In-Reply-To: <010401c6a075$ee6f7ee0$0000fea9@ohr.berkeley.edu> References: <010401c6a075$ee6f7ee0$0000fea9@ohr.berkeley.edu> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] Inconsistency between FETCH_DIM_IS and FETCH_OBJ_IS From: helly@php.net (Marcus Boerger) Hello Sara, nice catch, fix looks pretty correct to me best regards marcus Wednesday, July 5, 2006, 10:59:35 PM, you wrote: > When executing ZEND_FETCH_OBJ_IS on a non-object, the handler dispatches > to zend_fetch_property_address_read_helper with type==BP_VAR_IS and ends > up generating an error (isset() is supposed to be quiet) here: > if (Z_TYPE_P(container) != IS_OBJECT || > !Z_OBJ_HT_P(container)->read_property) { > zend_error(E_NOTICE, "Trying to get property of non-object"); > *retval = EG(uninitialized_zval_ptr); > SELECTIVE_PZVAL_LOCK(*retval, &opline->result); > AI_USE_PTR(EX_T(opline->result.u.var).var); > It's cousin ZEND_FETCH_DIM_IS winds up at zend_fetch_dimension_address() > where the non-arrayness of op1 is handled via these case statements: > case IS_NULL: { > /* for read-mode only */ > if (result) { > result->var.ptr_ptr = &EG(uninitialized_zval_ptr); > PZVAL_LOCK(*result->var.ptr_ptr); > } > if (type==BP_VAR_W || type==BP_VAR_RW) { > zend_error(E_WARNING, "Cannot use a NULL value as an array"); > } > break; > } > default: { > switch (type) { > case BP_VAR_UNSET: > zend_error(E_WARNING, "Cannot unset offset in a non-array variable"); > /* break missing intentionally */ > case BP_VAR_R: > case BP_VAR_IS: > retval = &EG(uninitialized_zval_ptr); > break; > default: > retval = &EG(error_zval_ptr); > break; > } > if (result) { > result->var.ptr_ptr = retval; > PZVAL_LOCK(*result->var.ptr_ptr); > } > if (type==BP_VAR_W || type==BP_VAR_RW) { > zend_error(E_WARNING, "Cannot use a scalar value as an array"); > } > } > Which indicate the expected behavior of silent failure. It's probably > gone undetected till now as it requires fetching a property or dimension > offset from a property in a third (non-object) variable within an isset() statement: > $foo = NULL; > isset($foo->bar->baz); > Unless someone can suggest why Objects should be noisy inside isset(), > I'd like to suggest the following fix: > Index: Zend/zend_vm_def.h > =================================================================== > RCS file: /repository/ZendEngine2/zend_vm_def.h,v > retrieving revision 1.120 > diff -u -r1.120 zend_vm_def.h > --- Zend/zend_vm_def.h 13 Jun 2006 12:56:20 -0000 1.120 > +++ Zend/zend_vm_def.h 5 Jul 2006 20:52:41 -0000 > @@ -1176,7 +1176,9 @@ > if (Z_TYPE_P(container) != IS_OBJECT || > !Z_OBJ_HT_P(container)->read_property) { > - zend_error(E_NOTICE, "Trying to get property of non-object"); > + if (type != BP_VAR_IS) { > + zend_error(E_NOTICE, "Trying to get property of non-object"); > + } > *retval = EG(uninitialized_zval_ptr); > SELECTIVE_PZVAL_LOCK(*retval, &opline->result); > AI_USE_PTR(EX_T(opline->result.u.var).var); > I suggest only excluding BP_VAR_IS since the matching behavior for > unset()/DIM is to throw a notice. I could potentially see excluding > BP_VAR_R in order to match read/DIM, but personally I never liked that behavior :) > -Sara Best regards, Marcus