]> granicus.if.org Git - php/commitdiff
- MF53 Fix for #41692, #42703
authorMarcus Boerger <helly@php.net>
Thu, 18 Oct 2007 05:26:55 +0000 (05:26 +0000)
committerMarcus Boerger <helly@php.net>
Thu, 18 Oct 2007 05:26:55 +0000 (05:26 +0000)
# Now in correct branch with fixed checkout and so on

ext/spl/spl_array.c
ext/spl/spl_iterators.c
ext/spl/tests/bug41692.phpt
ext/spl/tests/bug42654.phpt

index e7520915dee07f75aa496c0ec1a90f17704e6dfa..c703f00f7bb3e5ff2c68642827146dddee7f7af1 100755 (executable)
@@ -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);
 }
 /* }}} */
 
index 75bfeed681285e3b584cf5626bea5add14fc2b22..e8aa53c0db7d802c21051da654e74f82862848f1 100755 (executable)
@@ -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;
 }
index c9b7d8d60f0ce4cacb6bee186cccc4708caa545b..8a2b958fc16aa167e4c48c3063f5aa6331293578 100644 (file)
@@ -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
index 20aad74b73423f8db7ad1421411a39c631e1b323..bac87e2310ad57c4af603441ead8dce21231d07a 100755 (executable)
@@ -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]=>