Skip to content

Commit e21a296

Browse files
committed
1 parent c064fc4 commit e21a296

35 files changed

+88
-14
lines changed

Zend/tests/enum/__sleep.phpt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,6 @@ enum Foo {
1313

1414
?>
1515
--EXPECTF--
16+
Deprecated: The __sleep() serialization hook has been deprecated. Implement __serialize() instead (or in addition, if support for old PHP versions is necessary) in %s on line %d
17+
1618
Fatal error: Enum Foo cannot include magic method __sleep in %s on line %d

Zend/tests/enum/__wakeup.phpt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,6 @@ enum Foo {
1313

1414
?>
1515
--EXPECTF--
16+
Deprecated: The __wakeup() serialization hook has been deprecated. Implement __unserialize() instead (or in addition, if support for old PHP versions is necessary) in %s on line %d
17+
1618
Fatal error: Enum Foo cannot include magic method __wakeup in %s on line %d

Zend/tests/lazy_objects/oss_fuzz_71446.phpt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,4 @@ $obj = $reflector->newLazyProxy(function() {
2020
serialize($obj);
2121
?>
2222
--EXPECTF--
23+
Deprecated: The __sleep() serialization hook has been deprecated. Implement __serialize() instead (or in addition, if support for old PHP versions is necessary) in %s on line %d

Zend/tests/lazy_objects/serialize___sleep.phpt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ try {
3636

3737
?>
3838
--EXPECTF--
39+
Deprecated: The __sleep() serialization hook has been deprecated. Implement __serialize() instead (or in addition, if support for old PHP versions is necessary) in %s on line %d
3940
Init on serialize and successful initialization
4041
string(27) "O:1:"C":1:{s:4:"%0C%0b";i:1;}"
4142
Init on serialize and failed initialization

Zend/tests/lazy_objects/serialize___sleep_initializes.phpt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ $obj = $reflector->newLazyProxy(function ($obj) {
3737
test('Proxy', $obj);
3838

3939
--EXPECTF--
40+
Deprecated: The __sleep() serialization hook has been deprecated. Implement __serialize() instead (or in addition, if support for old PHP versions is necessary) in %s on line %d
4041
# Ghost:
4142
string(11) "initializer"
4243
string(24) "O:1:"C":1:{s:1:"a";i:1;}"

Zend/tests/lazy_objects/serialize___sleep_skip_flag.phpt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ $obj = $reflector->newLazyProxy(function ($obj) {
3535
test('Proxy', $obj);
3636

3737
--EXPECTF--
38+
Deprecated: The __sleep() serialization hook has been deprecated. Implement __serialize() instead (or in addition, if support for old PHP versions is necessary) in %s on line %d
3839
# Ghost:
3940
string(12) "O:1:"C":0:{}"
4041
object(C)#%d (0) {

Zend/tests/lazy_objects/serialize___sleep_skip_flag_may_initialize.phpt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ $obj = $reflector->newLazyProxy(function ($obj) {
3838
test('Proxy', $obj);
3939

4040
--EXPECTF--
41+
Deprecated: The __sleep() serialization hook has been deprecated. Implement __serialize() instead (or in addition, if support for old PHP versions is necessary) in %s on line %d
4142
# Ghost:
4243
string(11) "initializer"
4344
int(1)

Zend/tests/serialize/bug34045.phpt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,6 @@ $db_str = serialize($db);
2424
$db2 = unserialize($db_str);
2525
echo "ok\n";
2626
?>
27-
--EXPECT--
27+
--EXPECTF--
28+
Deprecated: The __wakeup() serialization hook has been deprecated. Implement __unserialize() instead (or in addition, if support for old PHP versions is necessary) in %s on line %d
2829
ok

Zend/zend_compile.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9272,6 +9272,15 @@ static void zend_compile_class_decl(znode *result, zend_ast *ast, bool toplevel)
92729272
ce->ce_flags |= ZEND_ACC_TOP_LEVEL;
92739273
}
92749274

9275+
if (UNEXPECTED(zend_hash_exists(&ce->function_table, ZSTR_KNOWN(ZEND_STR_SLEEP)) && ce->__serialize == NULL)) {
9276+
zend_error(E_DEPRECATED, "The __sleep() serialization hook has been deprecated."
9277+
" Implement __serialize() instead (or in addition, if support for old PHP versions is necessary)");
9278+
}
9279+
if (UNEXPECTED(zend_hash_exists(&ce->function_table, ZSTR_KNOWN(ZEND_STR_WAKEUP)) && ce->__unserialize == NULL)) {
9280+
zend_error(E_DEPRECATED, "The __wakeup() serialization hook has been deprecated."
9281+
" Implement __unserialize() instead (or in addition, if support for old PHP versions is necessary)");
9282+
}
9283+
92759284
/* We currently don't early-bind classes that implement interfaces or use traits */
92769285
if (!ce->num_interfaces && !ce->num_traits && !ce->num_hooked_prop_variance_checks
92779286
#ifdef ZEND_OPCACHE_SHM_REATTACHMENT

ext/standard/tests/serialize/001.phpt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
--TEST--
2-
serialize()/unserialize()/var_dump()
2+
serialize()/unserialize()/var_dump() using __sleep() and __wakeup()
33
--INI--
44
serialize_precision=100
55
--FILE--
@@ -78,6 +78,9 @@ $a = unserialize($data);
7878
var_dump($a);
7979
?>
8080
--EXPECTF--
81+
Deprecated: The __sleep() serialization hook has been deprecated. Implement __serialize() instead (or in addition, if support for old PHP versions is necessary) in %s on line %d
82+
83+
Deprecated: The __wakeup() serialization hook has been deprecated. Implement __unserialize() instead (or in addition, if support for old PHP versions is necessary) in %s on line %d
8184
N;
8285
b:1;
8386
b:0;

0 commit comments

Comments
 (0)