summaryrefslogtreecommitdiffstats
path: root/e24aca97b8925ac9d21f718c0e38274bde949866.patch
blob: 4d6e4448848355d9977a7d4a4308e8f13d0be96c (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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
From e24aca97b8925ac9d21f718c0e38274bde949866 Mon Sep 17 00:00:00 2001
From: Tyson Andre <tysonandre775@hotmail.com>
Date: Sat, 11 Apr 2020 15:14:41 -0400
Subject: [PATCH] Fix 2 of the test failures in php8

serialize() started throwing an exception in later releases of php 7.4
for uninitialized typed properties, so these no longer need tests of
unserialization.

The way php serializes floats (avoiding losing precision when
unserializing) seems to have changed.
---
 tests/__serialize_015.phpt      |  1 -
 tests/__serialize_015_php8.phpt | 58 ---------------------------------
 tests/igbinary_044.phpt         | 36 ++++++++++----------
 3 files changed, 18 insertions(+), 77 deletions(-)
 delete mode 100644 tests/__serialize_015_php8.phpt

diff --git a/tests/__serialize_015.phpt b/tests/__serialize_015.phpt
index 0610e50..66816ed 100644
--- a/tests/__serialize_015.phpt
+++ b/tests/__serialize_015.phpt
@@ -3,7 +3,6 @@ __serialize() mechanism (015): Uninitialized properties from __sleep should thro
 --SKIPIF--
 <?php
 if (PHP_VERSION_ID < 70400) { echo "skip __serialize/__unserialize not supported in php < 7.4 for compatibility with igbinary_serialize()"; }
-if (PHP_VERSION_ID >= 80000) { echo "skip different error message format"; }
 ?>
 --FILE--
 <?php
diff --git a/tests/__serialize_015_php8.phpt b/tests/__serialize_015_php8.phpt
deleted file mode 100644
index 8eda7b0..0000000
--- a/tests/__serialize_015_php8.phpt
+++ /dev/null
@@ -1,58 +0,0 @@
---TEST--
-__serialize() mechanism (015): Uninitialized properties from __sleep can be serialized and unserialized
---SKIPIF--
-<?php if (PHP_VERSION_ID < 80000) { echo "skip __serialize/__unserialize error message different in php < 8"; } ?>
---FILE--
-<?php
-error_reporting(E_ALL);
-set_error_handler(function ($errno, $message) {
-    echo $message . "\n";
-});
-class OSI {
-    public stdClass $o;
-    public string $s;
-    public ?int $i;
-    public float $f;
-    public function __sleep() {
-        return ['o', 's', 'i'];
-    }
-}
-// 00000002               -- header
-// 17 03 4d79436c617373   -- object of type "MyClass"
-//   14 03 000000           -- with 3 uninitialized properties
-$m = new OSI();
-var_dump($m);
-var_dump($s = serialize($m));
-try {
-    var_dump(unserialize($s));
-} catch (Error $e) {
-    // TODO: Double check if this is a deliberate design decision.
-    echo "unserialize: {$e->getMessage()}\n";
-}
-var_dump(bin2hex($s = igbinary_serialize($m)));
-try {
-    var_dump(igbinary_unserialize($s));
-} catch (Error $e) {
-    echo "igbinary_unserialize: {$e->getMessage()}\n";
-}
---EXPECT--
-object(OSI)#2 (0) {
-  ["o"]=>
-  uninitialized(stdClass)
-  ["s"]=>
-  uninitialized(string)
-  ["i"]=>
-  uninitialized(?int)
-  ["f"]=>
-  uninitialized(float)
-}
-serialize(): "o" returned as member variable from __sleep() but does not exist
-serialize(): "s" returned as member variable from __sleep() but does not exist
-serialize(): "i" returned as member variable from __sleep() but does not exist
-string(44) "O:3:"OSI":3:{s:1:"o";N;s:1:"s";N;s:1:"i";N;}"
-unserialize: Cannot assign null to property OSI::$o of type stdClass
-igbinary_serialize(): "o" returned as member variable from __sleep() but does not exist
-igbinary_serialize(): "s" returned as member variable from __sleep() but does not exist
-igbinary_serialize(): "i" returned as member variable from __sleep() but does not exist
-string(46) "0000000217034f5349140311016f001101730011016900"
-igbinary_unserialize: Cannot assign null to property OSI::$o of type stdClass
\ No newline at end of file
diff --git a/tests/igbinary_044.phpt b/tests/igbinary_044.phpt
index bcf1c89..1d37aa2 100644
--- a/tests/igbinary_044.phpt
+++ b/tests/igbinary_044.phpt
@@ -67,50 +67,50 @@ test('double min',  -1.7976931348623157e308);
 
 --EXPECTF--
 double subnormal:
-float(-4.9445841251603E-314)
-float(-4.9445841251603E-314)
+float(-4.944584125%S-314)
+float(-4.944584125%S-314)
    6         5         4         3         2         1
 3210987654321098765432109876543210987654321098765432109876543210
 1000000000000000000000000000001001010100100001010011000101110110
 
 double 1 max subnormal:
-float(2.2250738585072E-308)
-float(2.2250738585072E-308)
+float(2.2250738585072%SE-308)
+float(2.2250738585072%SE-308)
    6         5         4         3         2         1
 3210987654321098765432109876543210987654321098765432109876543210
 0000000000001111111111111111111111111111111111111111111111111111
 
 double 2 max subnormal:
-float(2.2250738585072E-308)
-float(2.2250738585072E-308)
+float(2.2250738585072%SE-308)
+float(2.2250738585072%SE-308)
    6         5         4         3         2         1
 3210987654321098765432109876543210987654321098765432109876543210
 0000000000001111111111111111111111111111111111111111111111111111
 
 double 3 max subnormal:
-float(2.2250738585072E-308)
-float(2.2250738585072E-308)
+float(2.2250738585072%SE-308)
+float(2.2250738585072%SE-308)
    6         5         4         3         2         1
 3210987654321098765432109876543210987654321098765432109876543210
 ACCEPTABLE
 
 double 4 max subnormal:
-float(2.2250738585072E-308)
-float(2.2250738585072E-308)
+float(2.2250738585072%SE-308)
+float(2.2250738585072%SE-308)
    6         5         4         3         2         1
 3210987654321098765432109876543210987654321098765432109876543210
 ACCEPTABLE
 
 double 5 max subnormal:
-float(2.2250738585072E-308)
-float(2.2250738585072E-308)
+float(2.2250738585072%SE-308)
+float(2.2250738585072%SE-308)
    6         5         4         3         2         1
 3210987654321098765432109876543210987654321098765432109876543210
 0000000000010000000000000000000000000000000000000000000000000000
 
 double min subnormal:
-float(-4.9406564584125E-324)
-float(-4.9406564584125E-324)
+float(-%SE-324)
+float(-%SE-324)
    6         5         4         3         2         1
 3210987654321098765432109876543210987654321098765432109876543210
 1000000000000000000000000000000000000000000000000000000000000001
@@ -123,8 +123,8 @@ float(-1.79769E+308)
 1111111111101111111111111111110001010111110010101000001010101110
 
 double max:
-float(1.7976931348623E+308)
-float(1.7976931348623E+308)
+float(1.7976931348623%SE+308)
+float(1.7976931348623%SE+308)
    6         5         4         3         2         1
 3210987654321098765432109876543210987654321098765432109876543210
 0111111111101111111111111111111111111111111111111111111111111111
@@ -137,8 +137,8 @@ float(-2.225E-308)
 1000000000001111111111111101110100110001101000000000110001101101
 
 double min:
-float(-1.7976931348623E+308)
-float(-1.7976931348623E+308)
+float(-1.7976931348623%SE+308)
+float(-1.7976931348623%SE+308)
    6         5         4         3         2         1
 3210987654321098765432109876543210987654321098765432109876543210
 1111111111101111111111111111111111111111111111111111111111111111