pollita Thu Oct 19 22:20:44 2006 UTC
Modified files:
/php-src/ext/spl spl_array.c
Log:
Fix working with ArrayObjects which contain arrays.
http://cvs.php.net/viewvc.cgi/php-src/ext/spl/spl_array.c?r1=1.113&r2=1.114&diff_format=u
Index: php-src/ext/spl/spl_array.c
diff -u php-src/ext/spl/spl_array.c:1.113 php-src/ext/spl/spl_array.c:1.114
--- php-src/ext/spl/spl_array.c:1.113 Sun Oct 8 10:50:19 2006
+++ php-src/ext/spl/spl_array.c Thu Oct 19 22:20:44 2006
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: spl_array.c,v 1.113 2006/10/08 10:50:19 bjori Exp $ */
+/* $Id: spl_array.c,v 1.114 2006/10/19 22:20:44 pollita Exp $ */
#ifdef HAVE_CONFIG_H
# include "config.h"
@@ -300,6 +300,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) {
@@ -316,7 +318,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) /* {{{ */
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php