From: Marcus Boerger Date: Mon, 4 Feb 2008 16:47:06 +0000 (+0000) Subject: - Fix ArrayObject serializing X-Git-Tag: RELEASE_2_0_0a1~625 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=3c7c97303d840718568ccca0694534dec6374494;p=php - Fix ArrayObject serializing - Fix test expectations --- diff --git a/ext/spl/spl_array.c b/ext/spl/spl_array.c index 6d12319b58..0f950b45c3 100755 --- a/ext/spl/spl_array.c +++ b/ext/spl/spl_array.c @@ -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; } /* }}} */ diff --git a/ext/spl/tests/array_023.phpt b/ext/spl/tests/array_023.phpt index 866cd4506a..a3cfdc5245 100644 --- a/ext/spl/tests/array_023.phpt +++ b/ext/spl/tests/array_023.phpt @@ -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 = 'tá'; - 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) "tá" + 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á" -object(Sláinte)#2 (4) { +string(3) "aaa" +object(Bla)#2 (4) { ["var"]=> - string(3) "tá" + 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" diff --git a/ext/spl/tests/bug41528.phpt b/ext/spl/tests/bug41528.phpt index 6be82c1820..9dade28cce 100644 --- a/ext/spl/tests/bug41528.phpt +++ b/ext/spl/tests/bug41528.phpt @@ -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) diff --git a/ext/spl/tests/bug42654.phpt b/ext/spl/tests/bug42654.phpt index 20aad74b73..55089ef28e 100755 --- a/ext/spl/tests/bug42654.phpt +++ b/ext/spl/tests/bug42654.phpt @@ -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" +} diff --git a/ext/spl/tests/bug42703.phpt b/ext/spl/tests/bug42703.phpt index 5c52763cd6..9ef29114cd 100755 --- a/ext/spl/tests/bug42703.phpt +++ b/ext/spl/tests/bug42703.phpt @@ -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 diff --git a/ext/spl/tests/spl_autoload_001.phpt b/ext/spl/tests/spl_autoload_001.phpt index 92a2ca96c0..ae7e5945f5 100755 --- a/ext/spl/tests/spl_autoload_001.phpt +++ b/ext/spl/tests/spl_autoload_001.phpt @@ -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=== diff --git a/ext/spl/tests/spl_autoload_007.phpt b/ext/spl/tests/spl_autoload_007.phpt index 00e41cd8bb..dbbedd2d38 100755 --- a/ext/spl/tests/spl_autoload_007.phpt +++ b/ext/spl/tests/spl_autoload_007.phpt @@ -59,16 +59,16 @@ foreach($funcs as $idx => $func) --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]=> diff --git a/ext/spl/tests/spl_autoload_008.phpt b/ext/spl/tests/spl_autoload_008.phpt index 228845fdf7..369b8303e0 100755 --- a/ext/spl/tests/spl_autoload_008.phpt +++ b/ext/spl/tests/spl_autoload_008.phpt @@ -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) {