Patch php-unserialize.patch for SPL related Bug #67453
Patch version 2014-06-16 12:18 UTC
Return to Bug #67453 |
Download this patch
Patch Revisions:
Developer: remi@php.net
diff -up ./ext/spl/spl_array.c.serialize ./ext/spl/spl_array.c
--- ./ext/spl/spl_array.c.serialize 2014-06-04 03:22:06.000000000 +0200
+++ ./ext/spl/spl_array.c 2014-06-16 09:06:10.821885032 +0200
@@ -1749,7 +1749,6 @@ SPL_METHOD(Array, unserialize)
}
if (buf_len == 0) {
- zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC, "Empty serialized string cannot be empty");
return;
}
diff -up ./ext/spl/spl_dllist.c.serialize ./ext/spl/spl_dllist.c
--- ./ext/spl/spl_dllist.c.serialize 2014-06-16 09:06:10.822885036 +0200
+++ ./ext/spl/spl_dllist.c 2014-06-16 09:07:01.601098042 +0200
@@ -1192,7 +1192,6 @@ SPL_METHOD(SplDoublyLinkedList, unserial
}
if (buf_len == 0) {
- zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC, "Serialized string cannot be empty");
return;
}
diff -up ./ext/spl/spl_observer.c.serialize ./ext/spl/spl_observer.c
--- ./ext/spl/spl_observer.c.serialize 2014-06-04 03:22:06.000000000 +0200
+++ ./ext/spl/spl_observer.c 2014-06-16 09:06:10.823885040 +0200
@@ -831,7 +831,6 @@ SPL_METHOD(SplObjectStorage, unserialize
}
if (buf_len == 0) {
- zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC, "Empty serialized string cannot be empty");
return;
}
diff -up ./ext/spl/tests/ArrayObject_unserialize_empty_string.phpt.serialize ./ext/spl/tests/ArrayObject_unserialize_empty_string.phpt
--- ./ext/spl/tests/ArrayObject_unserialize_empty_string.phpt.serialize 2014-06-04 03:22:06.000000000 +0200
+++ ./ext/spl/tests/ArrayObject_unserialize_empty_string.phpt 2014-06-16 09:06:10.824885044 +0200
@@ -1,5 +1,5 @@
--TEST--
-ArrayObject: test that you cannot unserialize a empty string
+ArrayObject: test that you can unserialize a empty string
--CREDITS--
Havard Eide <nucleuz@gmail.com>
#PHPTestFest2009 Norway 2009-06-09 \o/
@@ -8,9 +8,6 @@ Havard Eide <nucleuz@gmail.com>
$a = new ArrayObject(array());
$a->unserialize("");
?>
+Done
--EXPECTF--
-Fatal error: Uncaught exception 'UnexpectedValueException' with message 'Empty serialized string cannot be empty' in %s.php:%d
-Stack trace:
-#0 %s(%d): ArrayObject->unserialize('')
-#1 {main}
- thrown in %s.php on line %d
+Done
diff -up ./ext/spl/tests/SplObjectStorage_unserialize_invalid_parameter3.phpt.serialize ./ext/spl/tests/SplObjectStorage_unserialize_invalid_parameter3.phpt
--- ./ext/spl/tests/SplObjectStorage_unserialize_invalid_parameter3.phpt.serialize 2014-06-04 03:22:06.000000000 +0200
+++ ./ext/spl/tests/SplObjectStorage_unserialize_invalid_parameter3.phpt 2014-06-16 09:06:10.824885044 +0200
@@ -1,5 +1,5 @@
--TEST--
-Check that SplObjectStorage::unserialize throws exception when NULL passed
+Check that SplObjectStorage::unserialize doesn't throws exception when NULL passed
--CREDITS--
PHPNW Testfest 2009 - Simon Westcott (swestcott@gmail.com)
--FILE--
@@ -14,6 +14,6 @@ try {
}
?>
+Done
--EXPECTF--
-Empty serialized string cannot be empty
-
+Done
diff -up ./ext/spl/tests/unserialize.phpt.serialize ./ext/spl/tests/unserialize.phpt
--- ./ext/spl/tests/unserialize.phpt.serialize 2014-06-16 09:06:10.824885044 +0200
+++ ./ext/spl/tests/unserialize.phpt 2014-06-16 09:06:10.824885044 +0200
@@ -0,0 +1,43 @@
+--TEST--
+SPL: unserialize with no data (for PHPUnit)
+--FILE--
+<?php
+
+$types = array('SplDoublyLinkedList', 'SplObjectStorage', 'ArrayObject');
+
+foreach ($types as $type) {
+ // serialize an empty new object
+ $exp = serialize(new $type());
+ // hack to instanciate an object without constructor
+ $str = sprintf('C:%d:"%s":0:{}', strlen($type), $type);
+ $obj = unserialize($str);
+ var_dump($obj);
+ // serialize result
+ $out = serialize($obj);
+ // both should match
+ var_dump($exp === $out);
+}
+?>
+===DONE===
+--EXPECTF--
+object(SplDoublyLinkedList)#%d (2) {
+ ["flags":"SplDoublyLinkedList":private]=>
+ int(0)
+ ["dllist":"SplDoublyLinkedList":private]=>
+ array(0) {
+ }
+}
+bool(true)
+object(SplObjectStorage)#%d (1) {
+ ["storage":"SplObjectStorage":private]=>
+ array(0) {
+ }
+}
+bool(true)
+object(ArrayObject)#%d (1) {
+ ["storage":"ArrayObject":private]=>
+ array(0) {
+ }
+}
+bool(true)
+===DONE===
|