summaryrefslogtreecommitdiffstats
path: root/php-serialize.patch
blob: 4de9a30861e7992785435c02483d372d6d3f548c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
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===