]> granicus.if.org Git - php/commitdiff
apply corrected fix
authorAntony Dovgal <tony2001@php.net>
Wed, 27 Jun 2007 12:38:20 +0000 (12:38 +0000)
committerAntony Dovgal <tony2001@php.net>
Wed, 27 Jun 2007 12:38:20 +0000 (12:38 +0000)
fix tests

ext/spl/spl_array.c
ext/spl/tests/iterator_026.phpt
ext/spl/tests/iterator_047.phpt

index 9212dace9fbdad608440b23219b5073f982e33cb..15b74d3ffbc4d68c3848c5c9efac4d5c220356dc 100755 (executable)
@@ -931,7 +931,7 @@ SPL_METHOD(Array, __construct)
 {
        zval *object = getThis();
        spl_array_object *intern;
-       zval *array;
+       zval **array;
        long ar_flags = 0;
        zend_class_entry *ce_get_iterator = zend_ce_iterator;
 
@@ -942,36 +942,40 @@ SPL_METHOD(Array, __construct)
 
        intern = (spl_array_object*)zend_object_store_get_object(object TSRMLS_CC);
 
-       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z/|lC", &array, &ar_flags, &ce_get_iterator) == FAILURE) {
+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Z|lC", &array, &ar_flags, &ce_get_iterator) == FAILURE) {
                php_set_error_handling(EH_NORMAL, NULL TSRMLS_CC);
                return;
        }
 
+       if (Z_TYPE_PP(array) == IS_ARRAY) {
+               SEPARATE_ZVAL_IF_NOT_REF(array);
+       }
+
        if (ZEND_NUM_ARGS() > 2) {
                intern->ce_get_iterator = ce_get_iterator;
        }
 
        ar_flags &= ~SPL_ARRAY_INT_MASK;
 
-       if (Z_TYPE_P(array) == IS_OBJECT && (Z_OBJ_HT_P(array) == &spl_handler_ArrayObject || Z_OBJ_HT_P(array) == &spl_handler_ArrayIterator)) {
+       if (Z_TYPE_PP(array) == IS_OBJECT && (Z_OBJ_HT_PP(array) == &spl_handler_ArrayObject || Z_OBJ_HT_PP(array) == &spl_handler_ArrayIterator)) {
                zval_ptr_dtor(&intern->array);
                if (ZEND_NUM_ARGS() == 1)
                {
-                       spl_array_object *other = (spl_array_object*)zend_object_store_get_object(array TSRMLS_CC);
+                       spl_array_object *other = (spl_array_object*)zend_object_store_get_object(*array TSRMLS_CC);
                        ar_flags = other->ar_flags & ~SPL_ARRAY_INT_MASK;
                }               
                ar_flags |= SPL_ARRAY_USE_OTHER;
-               intern->array = array;
+               intern->array = *array;
        } else {
-               if (Z_TYPE_P(array) != IS_OBJECT && Z_TYPE_P(array) != IS_ARRAY) {
+               if (Z_TYPE_PP(array) != IS_OBJECT && Z_TYPE_PP(array) != IS_ARRAY) {
                        php_set_error_handling(EH_NORMAL, NULL TSRMLS_CC);
                        zend_throw_exception(spl_ce_InvalidArgumentException, "Passed variable is not an array or object, using empty array instead", 0 TSRMLS_CC);
                        return;
                }
                zval_ptr_dtor(&intern->array);
-               intern->array = array;
+               intern->array = *array;
        }
-       if (object == array) {
+       if (object == *array) {
                intern->ar_flags |= SPL_ARRAY_IS_SELF;
                intern->ar_flags &= ~SPL_ARRAY_USE_OTHER;
        } else {
@@ -979,12 +983,12 @@ SPL_METHOD(Array, __construct)
        }
        intern->ar_flags |= ar_flags;
        ZVAL_ADDREF(intern->array);
-       if (Z_TYPE_P(array) == IS_OBJECT) {
-               zend_object_get_properties_t handler = Z_OBJ_HANDLER_P(array, get_properties);
+       if (Z_TYPE_PP(array) == IS_OBJECT) {
+               zend_object_get_properties_t handler = Z_OBJ_HANDLER_PP(array, get_properties);
                if ((handler != std_object_handlers.get_properties && handler != spl_array_get_properties)
                || !spl_array_get_hash_table(intern, 0 TSRMLS_CC)) {
                        php_set_error_handling(EH_NORMAL, NULL TSRMLS_CC);
-                       zend_throw_exception_ex(spl_ce_InvalidArgumentException, 0 TSRMLS_CC, "Overloaded object of type %v is not compatible with %v", Z_OBJCE_P(array)->name, intern->std.ce->name);
+                       zend_throw_exception_ex(spl_ce_InvalidArgumentException, 0 TSRMLS_CC, "Overloaded object of type %v is not compatible with %v", Z_OBJCE_PP(array)->name, intern->std.ce->name);
                        return;
                }
        }
index 4c6fcf73b565beaf199e9a98746f9a66861fcf00..9f20998f3bcdbf2ff97c191215e5dda910b190df 100755 (executable)
@@ -20,15 +20,19 @@ foreach($it as $k=>$v)
 ?>
 ===DONE===
 <?php exit(0); ?>
---EXPECT--
+--EXPECTF--
 0=>1
 hasNext: yes
 1=>2
 hasNext: yes
+
+Notice: Array to string conversion in %s on line %d
 0=>31
 hasNext: yes
 1=>32
 hasNext: yes
+
+Notice: Array to string conversion in %s on line %d
 0=>331
 hasNext: no
 3=>4
index b313df3012d34480c0e4214fbc35822d9fef16fb..727cbc32d990267984f519928b5dcebfe59d3485 100755 (executable)
@@ -72,6 +72,8 @@ int(0)
 int(0)
 MyRecursiveArrayIterator::hasChildren()
 MyRecursiveArrayIterator::getChildren()
+
+Notice: Array to string conversion in %s on line %d
 MyRecursiveArrayIterator::hasChildren()
 int(0)
 int(10)
@@ -80,6 +82,8 @@ int(2)
 int(2)
 MyRecursiveArrayIterator::hasChildren()
 MyRecursiveArrayIterator::getChildren()
+
+Notice: Array to string conversion in %s on line %d
 MyRecursiveArrayIterator::hasChildren()
 int(0)
 int(30)
@@ -88,20 +92,22 @@ int(4)
 int(4)
 ===1===
 MyRecursiveArrayIterator::hasChildren()
-Exception: State 1: MyRecursiveArrayIterator::hasChildren() in %siterator_047.php on line %d
+Exception: State 1: MyRecursiveArrayIterator::hasChildren() in %s on line %d
 ===2===
 MyRecursiveArrayIterator::hasChildren()
 int(0)
 int(0)
 MyRecursiveArrayIterator::hasChildren()
 MyRecursiveArrayIterator::getChildren()
-Exception: State 2: MyRecursiveArrayIterator::getChildren() in %siterator_047.php on line %d
+Exception: State 2: MyRecursiveArrayIterator::getChildren() in %s on line %d
 ===3===
 MyRecursiveArrayIterator::hasChildren()
 int(0)
 int(0)
 MyRecursiveArrayIterator::hasChildren()
 MyRecursiveArrayIterator::getChildren()
+
+Notice: Array to string conversion in %s on line %d
 MyRecursiveArrayIterator::hasChildren()
 int(0)
 int(10)
@@ -110,6 +116,8 @@ int(2)
 int(2)
 MyRecursiveArrayIterator::hasChildren()
 MyRecursiveArrayIterator::getChildren()
+
+Notice: Array to string conversion in %s on line %d
 MyRecursiveArrayIterator::hasChildren()
 int(0)
 int(30)