]> granicus.if.org Git - php/commitdiff
- Fix ArrayObject serializing
authorMarcus Boerger <helly@php.net>
Mon, 4 Feb 2008 16:47:06 +0000 (16:47 +0000)
committerMarcus Boerger <helly@php.net>
Mon, 4 Feb 2008 16:47:06 +0000 (16:47 +0000)
- Fix test expectations

ext/spl/spl_array.c
ext/spl/tests/array_023.phpt
ext/spl/tests/bug41528.phpt
ext/spl/tests/bug42654.phpt
ext/spl/tests/bug42703.phpt
ext/spl/tests/spl_autoload_001.phpt
ext/spl/tests/spl_autoload_007.phpt
ext/spl/tests/spl_autoload_008.phpt

index 6d12319b5828cf22f737222ba63cd9c519fff484..0f950b45c3e04ce3ddb6b2cb6a8ce50516150137 100755 (executable)
@@ -1483,16 +1483,14 @@ SPL_METHOD(Array, unserialize)
 {
        spl_array_object *intern = (spl_array_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
        
-       zstr buf;
-       unsigned int buf_len;
-       UChar *p, *s;
-       zend_uchar buf_type; 
-               
+       char *buf;
+       int buf_len;
+       const unsigned char *p, *s;
        php_unserialize_data_t var_hash;
        zval *pentry, *pmembers, *pflags = NULL;
        long flags;
        
-       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "t", &buf, &buf_len, &buf_type) == FAILURE) {
+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &buf, &buf_len) == FAILURE) {
                return;
        }
 
@@ -1501,8 +1499,7 @@ SPL_METHOD(Array, unserialize)
                return;
        }
 
-       s = p = (buf_type == IS_UNICODE ? buf.u : (UChar *)buf.s);
-
+       s = p = (const unsigned char*)buf;
        PHP_VAR_UNSERIALIZE_INIT(var_hash);
 
        if (*p!= 'x' || *++p != ':') {
@@ -1569,7 +1566,7 @@ SPL_METHOD(Array, unserialize)
 
 outexcept:
        PHP_VAR_UNSERIALIZE_DESTROY(var_hash);
-       zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC, "Error at offset %ld of %d bytes", (long)((char*)p - (long)(buf_type == IS_UNICODE ? buf.u : (UChar *)buf.s)), buf_len);
+       zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC, "Error at offset %ld of %d bytes", (long)((char*)p - (long)buf), buf_len);
        return;
 
 } /* }}} */
index 866cd4506aff66281337c9fd878f76dc2cb763cd..a3cfdc5245442f921756b9941a51ac69dc7ed19c 100644 (file)
@@ -19,14 +19,14 @@ $a = unserialize(serialize($a));
 var_dump($a);
 var_dump($a->var);
 
-class Sláinte extends ArrayObject
+class Bla extends ArrayObject
 {
-    public $var = '';
-    protected $bar = 'trí';
-    private $foo = '';
+    public $var = 'aaa';
+    protected $bar = 'bbb';
+    private $foo = 'ccc';
 }
 
-$a = new Sláinte();
+$a = new Bla();
 var_dump($a);
 var_dump($a->var);
 
@@ -61,27 +61,76 @@ object(Name)#2 (4) {
   }
 }
 string(1) "a"
-object(Sláinte)#1 (4) {
+object(Bla)#1 (4) {
   ["var"]=>
-  string(3) ""
+  string(3) "aaa"
   ["bar":protected]=>
-  string(4) "trí"
-  ["foo":"Sláinte":private]=>
-  string(3) ""
+  string(3) "bbb"
+  ["foo":"Bla":private]=>
+  string(3) "ccc"
   ["storage":"ArrayObject":private]=>
   array(0) {
   }
 }
-string(3) ""
-object(Sláinte)#2 (4) {
+string(3) "aaa"
+object(Bla)#2 (4) {
   ["var"]=>
-  string(3) ""
+  string(3) "aaa"
   ["bar":protected]=>
-  string(4) "trí"
-  ["foo":"Sláinte":private]=>
-  string(3) ""
+  string(3) "bbb"
+  ["foo":"Bla":private]=>
+  string(3) "ccc"
   ["storage":"ArrayObject":private]=>
   array(0) {
   }
 }
-string(3) "tá"
+string(3) "aaa"
+--UEXPECT--
+object(Name)#1 (4) {
+  [u"var"]=>
+  unicode(1) "a"
+  [u"bar":protected]=>
+  unicode(1) "b"
+  [u"foo":u"Name":private]=>
+  unicode(1) "c"
+  [u"storage":u"ArrayObject":private]=>
+  array(0) {
+  }
+}
+unicode(1) "a"
+object(Name)#2 (4) {
+  [u"var"]=>
+  unicode(1) "a"
+  [u"bar":protected]=>
+  unicode(1) "b"
+  [u"foo":u"Name":private]=>
+  unicode(1) "c"
+  [u"storage":u"ArrayObject":private]=>
+  array(0) {
+  }
+}
+unicode(1) "a"
+object(Bla)#1 (4) {
+  [u"var"]=>
+  unicode(3) "aaa"
+  [u"bar":protected]=>
+  unicode(3) "bbb"
+  [u"foo":u"Bla":private]=>
+  unicode(3) "ccc"
+  [u"storage":u"ArrayObject":private]=>
+  array(0) {
+  }
+}
+unicode(3) "aaa"
+object(Bla)#2 (4) {
+  [u"var"]=>
+  unicode(3) "aaa"
+  [u"bar":protected]=>
+  unicode(3) "bbb"
+  [u"foo":u"Bla":private]=>
+  unicode(3) "ccc"
+  [u"storage":u"ArrayObject":private]=>
+  array(0) {
+  }
+}
+unicode(3) "aaa"
index 6be82c1820fdb8dfb51accdb33484236194f664c..9dade28cce763b6ebe9956034341d1868881786a 100644 (file)
@@ -35,3 +35,20 @@ object(ClassOne)#2 (2) {
   }
 }
 int(1)
+--UEXPECT--
+object(ClassOne)#1 (2) {
+  [u"a"]=>
+  int(1)
+  [u"storage":u"ArrayObject":private]=>
+  array(0) {
+  }
+}
+int(1)
+object(ClassOne)#2 (2) {
+  [u"a"]=>
+  int(1)
+  [u"storage":u"ArrayObject":private]=>
+  array(0) {
+  }
+}
+int(1)
index 20aad74b73423f8db7ad1421411a39c631e1b323..55089ef28e04133934b93f10590a5d52423a0fc3 100755 (executable)
@@ -156,3 +156,138 @@ array(3) {
   [4]=>
   string(5) "alter"
 }
+--UEXPECTF--
+update 1
+object(RecursiveArrayIterator)#%d (1) {
+  [u"storage":u"ArrayIterator":private]=>
+  array(3) {
+    [1]=>
+    unicode(4) "val1"
+    [2]=>
+    array(2) {
+      [2]=>
+      unicode(4) "val2"
+      [3]=>
+      array(1) {
+        [3]=>
+        unicode(4) "val3"
+      }
+    }
+    [4]=>
+    unicode(4) "val4"
+  }
+}
+object(RecursiveArrayIterator)#%d (1) {
+  [u"storage":u"ArrayIterator":private]=>
+  array(3) {
+    [1]=>
+    unicode(5) "alter"
+    [2]=>
+    array(2) {
+      [2]=>
+      unicode(4) "val2"
+      [3]=>
+      array(1) {
+        [3]=>
+        unicode(4) "val3"
+      }
+    }
+    [4]=>
+    unicode(4) "val4"
+  }
+}
+update 2
+object(RecursiveArrayIterator)#%d (1) {
+  [u"storage":u"ArrayIterator":private]=>
+  array(2) {
+    [2]=>
+    unicode(4) "val2"
+    [3]=>
+    array(1) {
+      [3]=>
+      unicode(4) "val3"
+    }
+  }
+}
+object(RecursiveArrayIterator)#%d (1) {
+  [u"storage":u"ArrayIterator":private]=>
+  array(2) {
+    [2]=>
+    unicode(5) "alter"
+    [3]=>
+    array(1) {
+      [3]=>
+      unicode(4) "val3"
+    }
+  }
+}
+update 3
+object(RecursiveArrayIterator)#%d (1) {
+  [u"storage":u"ArrayIterator":private]=>
+  array(1) {
+    [3]=>
+    unicode(4) "val3"
+  }
+}
+object(RecursiveArrayIterator)#%d (1) {
+  [u"storage":u"ArrayIterator":private]=>
+  array(1) {
+    [3]=>
+    unicode(5) "alter"
+  }
+}
+update 4
+object(RecursiveArrayIterator)#%d (1) {
+  [u"storage":u"ArrayIterator":private]=>
+  array(3) {
+    [1]=>
+    unicode(5) "alter"
+    [2]=>
+    array(2) {
+      [2]=>
+      unicode(4) "val2"
+      [3]=>
+      array(1) {
+        [3]=>
+        unicode(4) "val3"
+      }
+    }
+    [4]=>
+    unicode(4) "val4"
+  }
+}
+object(RecursiveArrayIterator)#%d (1) {
+  [u"storage":u"ArrayIterator":private]=>
+  array(3) {
+    [1]=>
+    unicode(5) "alter"
+    [2]=>
+    array(2) {
+      [2]=>
+      unicode(4) "val2"
+      [3]=>
+      array(1) {
+        [3]=>
+        unicode(4) "val3"
+      }
+    }
+    [4]=>
+    unicode(5) "alter"
+  }
+}
+array(3) {
+  [1]=>
+  unicode(5) "alter"
+  [2]=>
+  array(2) {
+    [2]=>
+    unicode(4) "val2"
+    [3]=>
+    array(1) {
+      [3]=>
+      unicode(4) "val3"
+    }
+  }
+  [4]=>
+  unicode(5) "alter"
+}
index 5c52763cd694dc696f33fdd5577a41b529b69b46..9ef29114cda48107d9cf1261d9a4df95c663f7c4 100755 (executable)
@@ -35,7 +35,11 @@ catch (Exception $e) {
 var_dump($itit->current());
 var_dump($itit->key());
 ?>
---EXPECTF--
+--EXPECT--
 string(3) "boo"
 NULL
 NULL
+--UEXPECT--
+unicode(3) "boo"
+NULL
+NULL
index 92a2ca96c0e8324a76bd067d6d7840f90b1bbd93..ae7e5945f5f8e2f6525f82b267abadb121bb5f10 100755 (executable)
@@ -134,7 +134,7 @@ TestFunc2(TestClass)
 %stestclass.class.inc
 bool(true)
 ===NOFUNCTION===
-Exception: Function 'unavailable_autoload_function' not found, (function 'unavailable_autoload_function' not found or invalid function name)
+Exception: Function 'unavailable_autoload_function' not found (function 'unavailable_autoload_function' not found or invalid function name)
 ===DONE===
 --UEXPECTF--
 ===EMPTY===
@@ -165,5 +165,5 @@ TestFunc2(TestClass)
 %stestclass.class.inc
 bool(true)
 ===NOFUNCTION===
-Exception: Function 'unavailable_autoload_function' not found, (function 'unavailable_autoload_function' not found or invalid function name)
+Exception: Function 'unavailable_autoload_function' not found (function 'unavailable_autoload_function' not found or invalid function name)
 ===DONE===
index 00e41cd8bb2bb973f63ce90d52ac1d8bf725e6ab..dbbedd2d386a3b36082ffe3309cc1dd9dcd12b25 100755 (executable)
@@ -59,16 +59,16 @@ foreach($funcs as $idx => $func)
 <?php exit(0); ?>
 --EXPECTF--
 string(22) "MyAutoLoader::notExist"
-Function 'MyAutoLoader::notExist' not found, (class 'MyAutoLoader' does not have a method 'notexist')
+Function 'MyAutoLoader::notExist' not found (class 'MyAutoLoader' does not have a method 'notexist')
 
 string(22) "MyAutoLoader::noAccess"
-Function 'MyAutoLoader::noAccess' not callable, (cannot access protected method MyAutoLoader::noAccess())
+Function 'MyAutoLoader::noAccess' not callable (cannot access protected method MyAutoLoader::noAccess())
 
 string(22) "MyAutoLoader::autoLoad"
 ok
 
 string(22) "MyAutoLoader::dynaLoad"
-Function 'MyAutoLoader::dynaLoad' not callable, (non-static method MyAutoLoader::dynaLoad() should not be called statically)
+Function 'MyAutoLoader::dynaLoad' not callable (non-static method MyAutoLoader::dynaLoad() should not be called statically)
 
 array(2) {
   [0]=>
@@ -140,16 +140,16 @@ ok
 ===DONE===
 --UEXPECTF--
 unicode(22) "MyAutoLoader::notExist"
-Function 'MyAutoLoader::notExist' not found, (class 'MyAutoLoader' does not have a method 'notexist')
+Function 'MyAutoLoader::notExist' not found (class 'MyAutoLoader' does not have a method 'notexist')
 
 unicode(22) "MyAutoLoader::noAccess"
-Function 'MyAutoLoader::noAccess' not callable, (cannot access protected method MyAutoLoader::noAccess())
+Function 'MyAutoLoader::noAccess' not callable (cannot access protected method MyAutoLoader::noAccess())
 
 unicode(22) "MyAutoLoader::autoLoad"
 ok
 
 unicode(22) "MyAutoLoader::dynaLoad"
-Function 'MyAutoLoader::dynaLoad' not callable, (non-static method MyAutoLoader::dynaLoad() should not be called statically)
+Function 'MyAutoLoader::dynaLoad' not callable (non-static method MyAutoLoader::dynaLoad() should not be called statically)
 
 array(2) {
   [0]=>
index 228845fdf7f0fd418d9bc013b64d073c6df39d86..369b8303e0b3cf4cb4ed95a58eadb4ace1366375 100755 (executable)
@@ -82,7 +82,7 @@ Exception: Bla
 int(0)
 ====2====
 string(22) "MyAutoLoader::dynaLoad"
-LogicException: Function 'MyAutoLoader::dynaLoad' not callable, (non-static method MyAutoLoader::dynaLoad() should not be called statically)
+LogicException: Function 'MyAutoLoader::dynaLoad' not callable (non-static method MyAutoLoader::dynaLoad() should not be called statically)
 int(0)
 ====3====
 array(2) {
@@ -144,7 +144,7 @@ Exception: Bla
 int(0)
 ====2====
 unicode(22) "MyAutoLoader::dynaLoad"
-LogicException: Function 'MyAutoLoader::dynaLoad' not callable, (non-static method MyAutoLoader::dynaLoad() should not be called statically)
+LogicException: Function 'MyAutoLoader::dynaLoad' not callable (non-static method MyAutoLoader::dynaLoad() should not be called statically)
 int(0)
 ====3====
 array(2) {