File tree Expand file tree Collapse file tree 2 files changed +14
-28
lines changed Expand file tree Collapse file tree 2 files changed +14
-28
lines changed Original file line number Diff line number Diff line change 1
1
--TEST--
2
- Referencing an uninitialized typed property in __sleep() should result in Error
2
+ Referencing an uninitialized typed property in __sleep() should be skipped
3
3
--FILE--
4
4
<?php
5
5
@@ -18,39 +18,27 @@ class Test {
18
18
}
19
19
20
20
$ t = new Test ;
21
- try {
22
- serialize ($ t );
23
- } catch (Error $ e ) {
24
- echo $ e ->getMessage (), "\n" ;
25
- }
21
+ var_dump (serialize ($ t ));
22
+ var_dump (unserialize (serialize ($ t )) == $ t );
26
23
27
24
$ t ->x = 1 ;
28
- try {
29
- serialize ($ t );
30
- } catch (Error $ e ) {
31
- echo $ e ->getMessage (), "\n" ;
32
- }
25
+ var_dump (unserialize (serialize ($ t )) == $ t );
33
26
34
27
$ t ->y = 2 ;
35
- try {
36
- serialize ($ t );
37
- } catch (Error $ e ) {
38
- echo $ e ->getMessage (), "\n" ;
39
- }
28
+ var_dump (unserialize (serialize ($ t )) == $ t );
40
29
41
30
$ t ->z = 3 ;
42
- try {
43
- var_dump (unserialize (serialize ($ t )));
44
- } catch (Error $ e ) {
45
- echo $ e ->getMessage (), "\n" ;
46
- }
31
+ var_dump (unserialize (serialize ($ t )) == $ t );
47
32
33
+ var_dump ($ t );
48
34
?>
49
35
--EXPECT--
50
- Typed property Test::$x must not be accessed before initialization (in __sleep)
51
- Typed property Test::$y must not be accessed before initialization (in __sleep)
52
- Typed property Test::$z must not be accessed before initialization (in __sleep)
53
- object(Test)#3 (3) {
36
+ string(15) "O:4:"Test":0:{}"
37
+ bool(true)
38
+ bool(true)
39
+ bool(true)
40
+ bool(true)
41
+ object(Test)#1 (3) {
54
42
["x"]=>
55
43
int(1)
56
44
["y":protected]=>
Original file line number Diff line number Diff line change @@ -777,9 +777,7 @@ static int php_var_serialize_try_add_sleep_prop(
777
777
if (Z_TYPE_P (val ) == IS_UNDEF ) {
778
778
zend_property_info * info = zend_get_typed_property_info_for_slot (Z_OBJ_P (struc ), val );
779
779
if (info ) {
780
- zend_throw_error (NULL ,
781
- "Typed property %s::$%s must not be accessed before initialization (in __sleep)" ,
782
- ZSTR_VAL (Z_OBJCE_P (struc )-> name ), ZSTR_VAL (error_name ));
780
+ return SUCCESS ;
783
781
}
784
782
return FAILURE ;
785
783
}
You can’t perform that action at this time.
0 commit comments