]> granicus.if.org Git - php/commitdiff
Fix Request #67453 Allow to unserialize empty data.
authorRemi Collet <remi@php.net>
Tue, 17 Jun 2014 07:38:54 +0000 (09:38 +0200)
committerRemi Collet <remi@php.net>
Tue, 17 Jun 2014 07:38:54 +0000 (09:38 +0200)
SplDoublyLinkedList, SplObjectStorage and ArrayObject have empty
constructor (no arg), so it make sense to allow to unserialize empty
data.

This allow the hack (used in various place, including PHPUnit) to
instanciate class without call to constructor to work.

ext/spl/spl_array.c
ext/spl/spl_dllist.c
ext/spl/spl_observer.c
ext/spl/tests/ArrayObject_unserialize_empty_string.phpt
ext/spl/tests/SplObjectStorage_unserialize_invalid_parameter3.phpt

index 9e3848dbfb03c75930bf06ce2048910212f6a530..4191b0db0e0b1b1ab2aa8a7b293776aae074a361 100644 (file)
@@ -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;
        }
 
index 772d780e014b06ce1508a7968a01f9b5d3f816b3..fb88f58908198e3f8092e350a503cc8d082af06d 100644 (file)
@@ -1192,7 +1192,6 @@ SPL_METHOD(SplDoublyLinkedList, unserialize)
        }
 
        if (buf_len == 0) {
-               zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC, "Serialized string cannot be empty");
                return;
        }
 
index 91830ab000da50d4a549a4bc0f304df7daa12647..57ddf492d1c2bf66a91d39bd1d15bd415538acac 100644 (file)
@@ -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;
        }
 
index 75d8a4132149ec0edd3e762cc96727bd2c21e6a7..4c446c82b9f0508e25e2f54f21fb4bb19ce9eb38 100644 (file)
@@ -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
index 4c2dd75e144b83f464ae1820a6526cd69286de16..617f85e63c800a97fec00b9f352012ce7b16c65a 100644 (file)
@@ -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