]> granicus.if.org Git - php/commitdiff
Fix #46192 (Serialization of ArrayObject with objects as storage)
authorEtienne Kneuss <colder@php.net>
Mon, 29 Sep 2008 22:42:49 +0000 (22:42 +0000)
committerEtienne Kneuss <colder@php.net>
Mon, 29 Sep 2008 22:42:49 +0000 (22:42 +0000)
ext/spl/spl_array.c
ext/spl/tests/array_025.phpt [new file with mode: 0644]

index 6f0bda0e2e8ad9d72c3da830ba3bf38e63957058..411c5ec47f79ab11a50cbe14ca0d7876f103c030 100755 (executable)
@@ -1594,7 +1594,7 @@ void spl_array_unserialize_helper(spl_array_object *intern, const unsigned char
        ++p;
 
        if (*p!='m') {
-               if (*p!='a') {
+               if (*p!='a' && *p!='O' && *p!='C') {
                        goto outexcept;
                }
                intern->ar_flags &= ~SPL_ARRAY_CLONE_MASK;
diff --git a/ext/spl/tests/array_025.phpt b/ext/spl/tests/array_025.phpt
new file mode 100644 (file)
index 0000000..35893ea
--- /dev/null
@@ -0,0 +1,40 @@
+--TEST--
+SPL: ArrayObject serialize with an object as storage
+--FILE--
+<?php
+$obj1 = new ArrayObject(new ArrayObject(array(1,2)));
+$s = serialize($obj1);
+$obj2 = unserialize($s);
+
+print_r($obj1);
+echo "$s\n";
+print_r($obj2);
+?>
+--EXPECT--
+ArrayObject Object
+(
+    [storage:ArrayObject:private] => ArrayObject Object
+        (
+            [storage:ArrayObject:private] => Array
+                (
+                    [0] => 1
+                    [1] => 2
+                )
+
+        )
+
+)
+C:11:"ArrayObject":76:{x:i:0;C:11:"ArrayObject":37:{x:i:0;a:2:{i:0;i:1;i:1;i:2;};m:a:0:{}};m:a:0:{}}
+ArrayObject Object
+(
+    [storage:ArrayObject:private] => ArrayObject Object
+        (
+            [storage:ArrayObject:private] => Array
+                (
+                    [0] => 1
+                    [1] => 2
+                )
+
+        )
+
+)