pollita Fri Oct 20 02:11:19 2006 UTC Modified files: (Branch: PHP_5_2) /php-src/ext/spl spl_array.c /php-src/ext/spl/tests iterator_035.phpt Log: MFH(r-1.114) Can't use real arrays held by ArrayObjects in write context http://cvs.php.net/viewvc.cgi/php-src/ext/spl/spl_array.c?r1=1.71.2.17.2.3&r2=1.71.2.17.2.4&diff_format=u Index: php-src/ext/spl/spl_array.c diff -u php-src/ext/spl/spl_array.c:1.71.2.17.2.3 php-src/ext/spl/spl_array.c:1.71.2.17.2.4 --- php-src/ext/spl/spl_array.c:1.71.2.17.2.3 Fri Aug 11 17:05:23 2006 +++ php-src/ext/spl/spl_array.c Fri Oct 20 02:11:19 2006 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: spl_array.c,v 1.71.2.17.2.3 2006/08/11 17:05:23 nlopess Exp $ */ +/* $Id: spl_array.c,v 1.71.2.17.2.4 2006/10/20 02:11:19 pollita Exp $ */ #ifdef HAVE_CONFIG_H # include "config.h" @@ -299,6 +299,8 @@ static zval *spl_array_read_dimension_ex(int check_inherited, zval *object, zval *offset, int type TSRMLS_DC) /* {{{ */ { + zval **ret; + if (check_inherited) { spl_array_object *intern = (spl_array_object*)zend_object_store_get_object(object TSRMLS_CC); if (intern->fptr_offset_get) { @@ -315,7 +317,30 @@ return EG(uninitialized_zval_ptr); } } - return *spl_array_get_dimension_ptr_ptr(check_inherited, object, offset, type TSRMLS_CC); + ret = spl_array_get_dimension_ptr_ptr(check_inherited, object, offset, type TSRMLS_CC); + + /* When in a write context, + * ZE has to be fooled into thinking this is in a reference set + * by separating (if necessary) and returning as an is_ref=1 zval (even if refcount == 1) */ + if ((type == BP_VAR_W || type == BP_VAR_RW) && !(*ret)->is_ref) { + if ((*ret)->refcount > 1) { + zval *newval; + + /* Separate */ + MAKE_STD_ZVAL(newval); + *newval = **ret; + zval_copy_ctor(newval); + newval->refcount = 1; + + /* Replace */ + (*ret)->refcount--; + *ret = newval; + } + + (*ret)->is_ref = 1; + } + + return *ret; } /* }}} */ static zval *spl_array_read_dimension(zval *object, zval *offset, int type TSRMLS_DC) /* {{{ */ http://cvs.php.net/viewvc.cgi/php-src/ext/spl/tests/iterator_035.phpt?r1=1.1.2.1&r2=1.1.2.1.2.1&diff_format=u Index: php-src/ext/spl/tests/iterator_035.phpt diff -u php-src/ext/spl/tests/iterator_035.phpt:1.1.2.1 php-src/ext/spl/tests/iterator_035.phpt:1.1.2.1.2.1 --- php-src/ext/spl/tests/iterator_035.phpt:1.1.2.1 Sat Apr 1 19:13:04 2006 +++ php-src/ext/spl/tests/iterator_035.phpt Fri Oct 20 02:11:19 2006 @@ -14,4 +14,4 @@ echo "Done\n"; ?> --EXPECTF-- -Fatal error: Objects used as arrays in post/pre increment/decrement must return values by reference in %s on line %d +Fatal error: Cannot assign by reference to overloaded object in %s on line %d
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php