Yes, I know.
My patch didn't remove "Fatal error" behavior, however may be it is
possible.

Dmitry.

> -----Original Message-----
> From: Hannes Magnusson [mailto:[EMAIL PROTECTED] 
> Sent: Thursday, November 09, 2006 2:17 PM
> To: Dmitry Stogov
> Cc: internals@lists.php.net; Andi Gutmans; Ilia Alshanetsky
> Subject: [PHP-DEV] Re: [ZEND-ENGINE-CVS] cvs: 
> ZendEngine2(PHP_5_2) / zend_object_handlers.c /tests 
> bug39297.phpt php-src NEWS
> 
> 
> Hi Dmitry!
> (moved to internal@)
> 
> On 11/8/06, Dmitry Stogov <[EMAIL PROTECTED]> wrote:
> > Hi,
> >
> > Please pay attention to this patch.
> > It makes overloaded arrays behave in exactly the same way as 
> > overloaded objects. It disables indirect modification of overloaded 
> > arrays and emits notices.
> It doesn't behave _exactly_ the same way...
> 
> <?php
> class foo implements ArrayAccess{
> public $bar;
> public function __get($var) {
>     return $this->bar;
> }
> public function offsetGet($var) {
>     return $this->bar;
> }
> public function offsetSet($var, $val) {}
> public function offsetExists($offset) {}
> public function offsetUnset($var) {}
> }
> 
> $foo = new foo;
> $bar =& $foo->prop;
> $bar =& $foo["prop"];
> PHP Notice:  Indirect modification of overloaded property 
> foo::$prop has no effect in /usr/src/php/5.2/- on line 16 PHP 
> Notice:  Indirect modification of overloaded element of foo 
> has no effect in /usr/src/php/5.2/- on line 17 PHP Fatal 
> error:  Objects used as arrays in post/pre 
> increment/decrement must return values by reference in
> /usr/src/php/5.2/- on line 17
> 
> But I guess this is expected behavior?
> 
> -Hannes
> >
> > The patch breaks (adds notice) three tests:
> >
> > test/classes/array_acess_005.phpt test/classes/array_acess_008.phpt
> > test/classes/array_acess_012.phpt
> >
> > Thanks. Dmitry.
> >
> > > -----Original Message-----
> > > From: Dmitry Stogov [mailto:[EMAIL PROTECTED]
> > > Sent: Wednesday, November 08, 2006 4:38 PM
> > > To: [EMAIL PROTECTED]
> > > Subject: [ZEND-ENGINE-CVS] cvs: ZendEngine2(PHP_5_2) / 
> > > zend_object_handlers.c /tests bug39297.phpt php-src NEWS
> > >
> > >
> > > dmitry                Wed Nov  8 13:38:29 2006 UTC
> > >
> > >   Added files:                 (Branch: PHP_5_2)
> > >     /ZendEngine2/tests        bug39297.phpt
> > >
> > >   Modified files:
> > >     /php-src  NEWS
> > >     /ZendEngine2      zend_object_handlers.c
> > >   Log:
> > >   Fixed bug #39297 (Memory corryption because of indirect 
> > > modification of overloaded array).
> > >
> > >
> > > http://cvs.php.net/viewvc.cgi/php-src/NEWS?r1=1.2027.2.547.2.3
> > > 39&r2=1.2027.2.547.2.340&diff_format=u
> > > Index: php-src/NEWS
> > > diff -u php-src/NEWS:1.2027.2.547.2.339 
> > > php-src/NEWS:1.2027.2.547.2.340
> > > --- php-src/NEWS:1.2027.2.547.2.339   Wed Nov  8 11:04:27 2006
> > > +++ php-src/NEWS      Wed Nov  8 13:38:28 2006
> > > @@ -30,6 +30,8 @@
> > >    an extension INI directive). (wharmby at uk dot ibm dot com, 
> > > Dmitry)
> > >  - Fixed bug #39320 (ZEND_HASH_APPLY_STOP causes 
> deletion). (Marcus)
> > >  - Fixed bug #39313 (spl_autoload triggers Fatal error). (Marcus)
> > > +- Fixed bug #39297 (Memory corryption because of indirect
> > > modification
> > > +  of overloaded array). (Dmitry)
> > >  - Fixed bug #39265 (Fixed path handling inside mod_files.sh).
> > >    (michal dot taborsky at gmail dot com, Ilia)
> > >  - Fixed bug #39215 (Inappropriate close of stdin/stdout/stderr). 
> > > (Wez,Ilia) 
> > > http://cvs.php.net/viewvc.cgi/ZendEngine2/zend_object_handlers
> > > .c?r1=1.135.2.6.2.15&r2=1.135.2.6.2.16&diff_format=u
> > > Index: ZendEngine2/zend_object_handlers.c
> > > diff -u ZendEngine2/zend_object_handlers.c:1.135.2.6.2.15
> > > ZendEngine2/zend_object_handlers.c:1.135.2.6.2.16
> > > --- ZendEngine2/zend_object_handlers.c:1.135.2.6.2.15 Tue Sep 12 
> > > 11:01:16 2006
> > > +++ ZendEngine2/zend_object_handlers.c        Wed Nov  8 
> 13:38:28 2006
> > > @@ -17,7 +17,7 @@
> > >
> > > +-------------------------------------------------------------
> > > ---------+
> > >  */
> > >
> > > -/* $Id: zend_object_handlers.c,v 1.135.2.6.2.15 
> 2006/09/12 11:01:16 
> > > dmitry Exp $ */
> > > +/* $Id: zend_object_handlers.c,v 1.135.2.6.2.16 
> 2006/11/08 13:38:28 
> > > +dmitry Exp $ */
> > >
> > >  #include "zend.h"
> > >  #include "zend_globals.h"
> > > @@ -469,6 +469,19 @@
> > >               /* Undo PZVAL_LOCK() */
> > >               retval->refcount--;
> > >
> > > +             if ((type == BP_VAR_W || type == BP_VAR_RW  ||
> > > type == BP_VAR_UNSET) && retval->refcount > 0) {
> > > +                     zval *tmp = retval;
> > > +
> > > +                     ALLOC_ZVAL(retval);
> > > +                     *retval = *tmp;
> > > +                     zval_copy_ctor(retval);
> > > +                     retval->is_ref = 0;
> > > +                     retval->refcount = 0;
> > > +                     if (Z_TYPE_P(retval) != IS_OBJECT) {
> > > +                             zend_error(E_NOTICE, "Indirect
> > > modification of overloaded element of %s has no effect", 
> ce->name);
> > > +                     }
> > > +             }
> > > +
> > >               return retval;
> > >       } else {
> > >               zend_error(E_ERROR, "Cannot use object of 
> type %s as 
> > > array", ce->name);
> > >
> > > http://cvs.php.net/viewvc.cgi/ZendEngine2/tests/bug39297.phpt?
> > view=markup&rev=1.1
> > Index: ZendEngine2/tests/bug39297.phpt
> > +++ ZendEngine2/tests/bug39297.phpt
> >
> > --
> > Zend Engine CVS Mailing List (http://cvs.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> > --
> > Zend Engine CVS Mailing List (http://cvs.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >
> 
> -- 
> PHP Internals - PHP Runtime Development Mailing List
> To unsubscribe, visit: http://www.php.net/unsub.php
> 

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to