Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:24281 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 64606 invoked by uid 1010); 6 Jul 2006 06:14:13 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 64591 invoked from network); 6 Jul 2006 06:14:13 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 6 Jul 2006 06:14:13 -0000 X-PHP-List-Original-Sender: andi@zend.com X-Host-Fingerprint: 80.74.107.235 mail.zend.com Linux 2.5 (sometimes 2.4) (4) Received: from ([80.74.107.235:19396] helo=mail.zend.com) by pb1.pair.com (ecelerity 2.1.1.3 r(11751M)) with ESMTP id 28/C3-16663-33AACA44 for ; Thu, 06 Jul 2006 02:14:13 -0400 Received: (qmail 8840 invoked from network); 6 Jul 2006 06:13:21 -0000 Received: from localhost (HELO ANDILENOVO) (127.0.0.1) by localhost with SMTP; 6 Jul 2006 06:13:21 -0000 To: "'Sara Golemon'" , Date: Wed, 5 Jul 2006 23:14:03 -0700 Message-ID: <004c01c6a0c3$638671a0$6500a8c0@zend.2k> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Mailer: Microsoft Office Outlook 11 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2869 Thread-Index: AcagdfzTv9TwVp7BR6qQR6h1rQHTeQATV8OQ In-Reply-To: <010401c6a075$ee6f7ee0$0000fea9@ohr.berkeley.edu> Subject: RE: [PHP-DEV] Inconsistency between FETCH_DIM_IS and FETCH_OBJ_IS From: andi@zend.com ("Andi Gutmans") References: <010401c6a075$ee6f7ee0$0000fea9@ohr.berkeley.edu> Looks good to me. Thanks! > -----Original Message----- > From: Sara Golemon [mailto:pollita@php.net] > Sent: Wednesday, July 05, 2006 2:00 PM > To: internals@lists.php.net > Subject: [PHP-DEV] Inconsistency between FETCH_DIM_IS and FETCH_OBJ_IS > > 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