From: Marcus Boerger Date: Thu, 18 Oct 2007 05:26:55 +0000 (+0000) Subject: - MF53 Fix for #41692, #42703 X-Git-Tag: php-5.2.5RC1~5 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=9f6936fc0c4cc31c2c68b7a218c439b836cc20d6;p=php - MF53 Fix for #41692, #42703 # Now in correct branch with fixed checkout and so on --- diff --git a/ext/spl/spl_array.c b/ext/spl/spl_array.c index e7520915de..c703f00f7b 100755 --- a/ext/spl/spl_array.c +++ b/ext/spl/spl_array.c @@ -1365,7 +1365,7 @@ SPL_METHOD(Array, hasChildren) Create a sub iterator for the current element (same class as $this) */ SPL_METHOD(Array, getChildren) { - zval *object = getThis(), **entry; + zval *object = getThis(), **entry, *flags; spl_array_object *intern = (spl_array_object*)zend_object_store_get_object(object TSRMLS_CC); HashTable *aht = spl_array_get_hash_table(intern, 0 TSRMLS_CC); @@ -1387,7 +1387,10 @@ SPL_METHOD(Array, getChildren) RETURN_ZVAL(*entry, 0, 0); } - spl_instantiate_arg_ex1(Z_OBJCE_P(getThis()), &return_value, 0, *entry TSRMLS_CC); + MAKE_STD_ZVAL(flags); + ZVAL_LONG(flags, SPL_ARRAY_USE_OTHER); + spl_instantiate_arg_ex2(intern->std.ce, &return_value, 0, *entry, flags TSRMLS_CC); + zval_ptr_dtor(&flags); } /* }}} */ diff --git a/ext/spl/spl_iterators.c b/ext/spl/spl_iterators.c index 75bfeed681..e8aa53c0db 100755 --- a/ext/spl/spl_iterators.c +++ b/ext/spl/spl_iterators.c @@ -1124,15 +1124,17 @@ static inline int spl_dual_it_fetch(spl_dual_it_object *intern, int check_more T spl_dual_it_free(intern TSRMLS_CC); if (!check_more || spl_dual_it_valid(intern TSRMLS_CC) == SUCCESS) { intern->inner.iterator->funcs->get_current_data(intern->inner.iterator, &data TSRMLS_CC); - intern->current.data = *data; - intern->current.data->refcount++; + if (data && *data) { + intern->current.data = *data; + intern->current.data->refcount++; + } if (intern->inner.iterator->funcs->get_current_key) { intern->current.key_type = intern->inner.iterator->funcs->get_current_key(intern->inner.iterator, &intern->current.str_key, &intern->current.str_key_len, &intern->current.int_key TSRMLS_CC); } else { intern->current.key_type = HASH_KEY_IS_LONG; intern->current.int_key = intern->current.pos; } - return SUCCESS; + return EG(exception) ? FAILURE : SUCCESS; } return FAILURE; } diff --git a/ext/spl/tests/bug41692.phpt b/ext/spl/tests/bug41692.phpt index c9b7d8d60f..8a2b958fc1 100644 --- a/ext/spl/tests/bug41692.phpt +++ b/ext/spl/tests/bug41692.phpt @@ -21,44 +21,20 @@ var_dump($bar); echo "Done\n"; ?> --EXPECTF-- -object(Bar)#%d (2) { - ["foo":"Bar":private]=> - array(3) { - [0]=> - int(1) - [1]=> - int(2) - [2]=> - int(3) - } - ["storage":"ArrayObject":private]=> - array(3) { - [0]=> - int(1) - [1]=> - int(2) - [2]=> - int(3) - } +object(Bar)#%d (3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) } -object(Bar)#%d (2) { - ["foo":"Bar":private]=> - array(3) { - [0]=> - int(1) - [1]=> - int(2) - [2]=> - int(3) - } - ["storage":"ArrayObject":private]=> - array(3) { - [0]=> - int(1) - [1]=> - int(2) - [2]=> - int(3) - } +object(Bar)#%d (3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) } Done diff --git a/ext/spl/tests/bug42654.phpt b/ext/spl/tests/bug42654.phpt index 20aad74b73..bac87e2310 100755 --- a/ext/spl/tests/bug42654.phpt +++ b/ext/spl/tests/bug42654.phpt @@ -23,47 +23,10 @@ var_dump($copy); ?> --EXPECTF-- update 1 -object(RecursiveArrayIterator)#%d (1) { - ["storage":"ArrayIterator":private]=> - array(3) { - [1]=> - string(4) "val1" - [2]=> - array(2) { - [2]=> - string(4) "val2" - [3]=> - array(1) { - [3]=> - string(4) "val3" - } - } - [4]=> - string(4) "val4" - } -} -object(RecursiveArrayIterator)#%d (1) { - ["storage":"ArrayIterator":private]=> - array(3) { - [1]=> - string(5) "alter" - [2]=> - array(2) { - [2]=> - string(4) "val2" - [3]=> - array(1) { - [3]=> - string(4) "val3" - } - } - [4]=> - string(4) "val4" - } -} -update 2 -object(RecursiveArrayIterator)#%d (1) { - ["storage":"ArrayIterator":private]=> +object(RecursiveArrayIterator)#%d (3) { + [1]=> + string(4) "val1" + [2]=> array(2) { [2]=> string(4) "val2" @@ -73,72 +36,85 @@ object(RecursiveArrayIterator)#%d (1) { string(4) "val3" } } + [4]=> + string(4) "val4" } -object(RecursiveArrayIterator)#%d (1) { - ["storage":"ArrayIterator":private]=> +object(RecursiveArrayIterator)#%d (3) { + [1]=> + string(5) "alter" + [2]=> array(2) { [2]=> - string(5) "alter" + string(4) "val2" [3]=> array(1) { [3]=> string(4) "val3" } } + [4]=> + string(4) "val4" } -update 3 -object(RecursiveArrayIterator)#%d (1) { - ["storage":"ArrayIterator":private]=> +update 2 +object(RecursiveArrayIterator)#%d (2) { + [2]=> + string(4) "val2" + [3]=> array(1) { [3]=> string(4) "val3" } } -object(RecursiveArrayIterator)#%d (1) { - ["storage":"ArrayIterator":private]=> +object(RecursiveArrayIterator)#%d (2) { + [2]=> + string(5) "alter" + [3]=> array(1) { [3]=> - string(5) "alter" + string(4) "val3" } } -update 4 +update 3 object(RecursiveArrayIterator)#%d (1) { - ["storage":"ArrayIterator":private]=> - array(3) { - [1]=> - string(5) "alter" + [3]=> + string(4) "val3" +} +object(RecursiveArrayIterator)#%d (1) { + [3]=> + string(5) "alter" +} +update 4 +object(RecursiveArrayIterator)#%d (3) { + [1]=> + string(5) "alter" + [2]=> + array(2) { [2]=> - array(2) { - [2]=> - string(4) "val2" + string(4) "val2" + [3]=> + array(1) { [3]=> - array(1) { - [3]=> - string(4) "val3" - } + string(4) "val3" } - [4]=> - string(4) "val4" } + [4]=> + string(4) "val4" } -object(RecursiveArrayIterator)#%d (1) { - ["storage":"ArrayIterator":private]=> - array(3) { - [1]=> - string(5) "alter" +object(RecursiveArrayIterator)#%d (3) { + [1]=> + string(5) "alter" + [2]=> + array(2) { [2]=> - array(2) { - [2]=> - string(4) "val2" + string(4) "val2" + [3]=> + array(1) { [3]=> - array(1) { - [3]=> - string(4) "val3" - } + string(4) "val3" } - [4]=> - string(5) "alter" } + [4]=> + string(5) "alter" } array(3) { [1]=>