Browse Source

- Fix ArrayObject serializing

- Fix test expectations
experimental/first_unicode_implementation
Marcus Boerger 19 years ago
parent
commit
3c7c97303d
  1. 15
      ext/spl/spl_array.c
  2. 83
      ext/spl/tests/array_023.phpt
  3. 17
      ext/spl/tests/bug41528.phpt
  4. 135
      ext/spl/tests/bug42654.phpt
  5. 6
      ext/spl/tests/bug42703.phpt
  6. 4
      ext/spl/tests/spl_autoload_001.phpt
  7. 12
      ext/spl/tests/spl_autoload_007.phpt
  8. 4
      ext/spl/tests/spl_autoload_008.phpt

15
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;
} /* }}} */

83
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 = '';
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"

17
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)

135
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"
}

6
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

4
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===

12
ext/spl/tests/spl_autoload_007.phpt

@ -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]=>

4
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) {

Loading…
Cancel
Save