1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 00:02:20 +01:00
Gina Peter Banyard
2025-09-11 06:57:21 +01:00
committed by GitHub
parent 2d545dd1b7
commit a5f2eee785
28 changed files with 100 additions and 5 deletions

View File

@@ -13,4 +13,6 @@ enum Foo {
?>
--EXPECTF--
Deprecated: The __wakeup() serialization magic method has been deprecated. Implement __unserialize() instead (or in addition, if support for old PHP versions is necessary) in %s on line %d
Fatal error: Enum Foo cannot include magic method __wakeup in %s on line %d

View File

@@ -24,5 +24,6 @@ $db_str = serialize($db);
$db2 = unserialize($db_str);
echo "ok\n";
?>
--EXPECT--
--EXPECTF--
Deprecated: The __wakeup() serialization magic method has been deprecated. Implement __unserialize() instead (or in addition, if support for old PHP versions is necessary) in %s on line %d
ok

View File

@@ -9355,6 +9355,10 @@ static void zend_compile_class_decl(znode *result, zend_ast *ast, bool toplevel)
zend_error(E_DEPRECATED, "The __sleep() serialization magic method has been deprecated."
" Implement __serialize() instead (or in addition, if support for old PHP versions is necessary)");
}
if (UNEXPECTED(zend_hash_exists(&ce->function_table, ZSTR_KNOWN(ZEND_STR_WAKEUP)) && ce->__unserialize == NULL)) {
zend_error(E_DEPRECATED, "The __wakeup() serialization magic method has been deprecated."
" Implement __unserialize() instead (or in addition, if support for old PHP versions is necessary)");
}
/* We currently don't early-bind classes that implement interfaces or use traits */
if (!ce->num_interfaces && !ce->num_traits && !ce->num_hooked_prop_variance_checks

View File

@@ -22,6 +22,8 @@ try {
var_dump( $foo );
?>
--EXPECTF--
Deprecated: The __wakeup() serialization magic method has been deprecated. Implement __unserialize() instead (or in addition, if support for old PHP versions is necessary) in %s on line %d
Fatal error: Uncaught Error: Invalid serialization data for DateTime object in %sbug62852_var2.php:%d
Stack trace:
#0 [internal function]: DateTime->__unserialize(Array)

View File

@@ -22,6 +22,8 @@ try {
var_dump( $foo );
?>
--EXPECTF--
Deprecated: The __wakeup() serialization magic method has been deprecated. Implement __unserialize() instead (or in addition, if support for old PHP versions is necessary) in %s on line %d
Fatal error: Uncaught Error: Invalid serialization data for DateTime object in %sbug62852_var3.php:%d
Stack trace:
#0 [internal function]: DateTime->__unserialize(Array)

View File

@@ -81,6 +81,8 @@ echo "Serialized:\n-----------\n$serialized\n-----------\nRestored:\n-----------
?>
--EXPECTF--
Deprecated: The __sleep() serialization magic method has been deprecated. Implement __serialize() instead (or in addition, if support for old PHP versions is necessary) in %s on line %d
Deprecated: The __wakeup() serialization magic method has been deprecated. Implement __unserialize() instead (or in addition, if support for old PHP versions is necessary) in %s on line %d
=== __sleep and __wakeup ===
string(144) "O:34:"SerializableDomDocumentSleepWakeup":1:{s:43:"%0SerializableDomDocumentSleepWakeup%0xmlData";s:39:"<?xml version="1.0"?>
<tag>value</tag>

View File

@@ -112,6 +112,8 @@ $db->exec('DROP TABLE IF EXISTS test_stmt_fetch_class');
--EXPECTF--
Deprecated: The __sleep() serialization magic method has been deprecated. Implement __serialize() instead (or in addition, if support for old PHP versions is necessary) in %s on line %d
Deprecated: The __wakeup() serialization magic method has been deprecated. Implement __unserialize() instead (or in addition, if support for old PHP versions is necessary) in %s on line %d
Deprecated: %s implements the Serializable interface, which is deprecated. Implement __serialize() and __unserialize() instead (or in addition, if support for old PHP versions is necessary) in %s on line %d
Creating an object, serializing it and writing it to DB...
myclass::singleton(Creating object)

View File

@@ -109,6 +109,8 @@ $db->exec('DROP TABLE IF EXISTS test_stmt_fetch_serialize');
--EXPECTF--
Deprecated: The __sleep() serialization magic method has been deprecated. Implement __serialize() instead (or in addition, if support for old PHP versions is necessary) in %s on line %d
Deprecated: The __wakeup() serialization magic method has been deprecated. Implement __unserialize() instead (or in addition, if support for old PHP versions is necessary) in %s on line %d
Deprecated: %s implements the Serializable interface, which is deprecated. Implement __serialize() and __unserialize() instead (or in addition, if support for old PHP versions is necessary) in %s on line %d
Creating an object, serializing it and writing it to DB...
myclass::singleton(Creating object)

View File

@@ -112,6 +112,8 @@ $db->exec('DROP TABLE IF EXISTS test_stmt_fetchserialize_fetch_class');
--EXPECTF--
Deprecated: The __sleep() serialization magic method has been deprecated. Implement __serialize() instead (or in addition, if support for old PHP versions is necessary) in %s on line %d
Deprecated: The __wakeup() serialization magic method has been deprecated. Implement __unserialize() instead (or in addition, if support for old PHP versions is necessary) in %s on line %d
Deprecated: %s implements the Serializable interface, which is deprecated. Implement __serialize() and __unserialize() instead (or in addition, if support for old PHP versions is necessary) in %s on line %d
Creating an object, serializing it and writing it to DB...
myclass::singleton(Creating object)

View File

@@ -58,6 +58,7 @@ unlink(__DIR__ . '/' . basename(__FILE__, '.clean.php') . '.phar.php');
unlink(__DIR__ . '/' . basename(__FILE__, '.clean.php') . '.phar.php.copy.php');
?>
--EXPECTF--
Deprecated: The __wakeup() serialization magic method has been deprecated. Implement __unserialize() instead (or in addition, if support for old PHP versions is necessary) in %s on line %d
Reading file contents through stream wrapper
string(18) "contents of file a"
Original metadata

View File

@@ -68,6 +68,8 @@ unlink(__DIR__ . '/' . basename(__FILE__, '.clean.php') . '.phar.php');
unlink(__DIR__ . '/' . basename(__FILE__, '.clean.php') . '.phar.php.copy.php');
?>
--EXPECTF--
Deprecated: The __wakeup() serialization magic method has been deprecated. Implement __unserialize() instead (or in addition, if support for old PHP versions is necessary) in %s on line %d
Deprecated: The __sleep() serialization magic method has been deprecated. Implement __serialize() instead (or in addition, if support for old PHP versions is necessary) in %s on line %d
In __destruct 1
string(1) "a"

View File

@@ -34,6 +34,7 @@ function ptr2str($ptr)
}
?>
--EXPECTF--
Deprecated: The __wakeup() serialization magic method has been deprecated. Implement __unserialize() instead (or in addition, if support for old PHP versions is necessary) in %s on line %d
array(5) {
[0]=>
int(1)

View File

@@ -34,6 +34,7 @@ function ptr2str($ptr)
}
?>
--EXPECTF--
Deprecated: The __wakeup() serialization magic method has been deprecated. Implement __unserialize() instead (or in addition, if support for old PHP versions is necessary) in %s on line %d
array(5) {
[0]=>
int(1)

View File

@@ -79,6 +79,8 @@ var_dump($a);
?>
--EXPECTF--
Deprecated: The __sleep() serialization magic method has been deprecated. Implement __serialize() instead (or in addition, if support for old PHP versions is necessary) in %s on line %d
Deprecated: The __wakeup() serialization magic method has been deprecated. Implement __unserialize() instead (or in addition, if support for old PHP versions is necessary) in %s on line %d
N;
b:1;
b:0;

View File

@@ -130,8 +130,12 @@ var_dump(unserialize('O:22:"autoload_not_available":0:{}'));
--EXPECTF--
Deprecated: The __sleep() serialization magic method has been deprecated. Implement __serialize() instead (or in addition, if support for old PHP versions is necessary) in %s on line %d
Deprecated: The __wakeup() serialization magic method has been deprecated. Implement __unserialize() instead (or in addition, if support for old PHP versions is necessary) in %s on line %d
Deprecated: The __sleep() serialization magic method has been deprecated. Implement __serialize() instead (or in addition, if support for old PHP versions is necessary) in %s on line %d
Deprecated: The __wakeup() serialization magic method has been deprecated. Implement __unserialize() instead (or in addition, if support for old PHP versions is necessary) in %s on line %d
Deprecated: %s implements the Serializable interface, which is deprecated. Implement __serialize() and __unserialize() instead (or in addition, if support for old PHP versions is necessary) in %s on line %d
===O1===
TestOld::__sleep()

View File

@@ -38,7 +38,8 @@ var_dump($s = serialize($obj));
var_dump(unserialize($s));
?>
--EXPECT--
--EXPECTF--
Deprecated: The __wakeup() serialization magic method has been deprecated. Implement __unserialize() instead (or in addition, if support for old PHP versions is necessary) in %s on line %d
string(126) "O:6:"Wakeup":1:{s:4:"data";a:1:{i:0;O:11:"Unserialize":1:{i:0;O:6:"Wakeup":1:{s:4:"data";a:1:{i:0;O:11:"Unserialize":0:{}}}}}}"
__unserialize() called
array(0) {

View File

@@ -20,5 +20,6 @@ try {
var_dump($e->getMessage());
}
?>
--EXPECT--
--EXPECTF--
Deprecated: The __wakeup() serialization magic method has been deprecated. Implement __unserialize() instead (or in addition, if support for old PHP versions is necessary) in %s on line %d
string(6) "Failed"

View File

@@ -75,6 +75,8 @@ function check(myObjC $obj) {
?>
--EXPECTF--
Deprecated: The __sleep() serialization magic method has been deprecated. Implement __serialize() instead (or in addition, if support for old PHP versions is necessary) in %s on line %d
Deprecated: The __wakeup() serialization magic method has been deprecated. Implement __unserialize() instead (or in addition, if support for old PHP versions is necessary) in %s on line %d
SCRIPT START
check successful
start serialize/unserialize

View File

@@ -25,7 +25,8 @@ for($i = 0; $i < 5; $i++) {
var_dump($data);
?>
--EXPECT--
--EXPECTF--
Deprecated: The __wakeup() serialization magic method has been deprecated. Implement __unserialize() instead (or in addition, if support for old PHP versions is necessary) in %s on line %d
array(2) {
[0]=>
object(evilClass)#1 (0) {

View File

@@ -23,6 +23,7 @@ var_dump($data);
?>
--EXPECTF--
Deprecated: The __wakeup() serialization magic method has been deprecated. Implement __unserialize() instead (or in addition, if support for old PHP versions is necessary) in %s on line %d
int(1)
array(2) {
[0]=>

View File

@@ -48,6 +48,8 @@ function ptr2str($ptr)
}
?>
--EXPECTF--
Deprecated: The __wakeup() serialization magic method has been deprecated. Implement __unserialize() instead (or in addition, if support for old PHP versions is necessary) in %s on line %d
Deprecated: obj implements the Serializable interface, which is deprecated. Implement __serialize() and __unserialize() instead (or in addition, if support for old PHP versions is necessary) in %s on line %d
array(2) {
[0]=>

View File

@@ -26,7 +26,8 @@ var_dump($x);
var_dump($obj);
?>
--EXPECT--
--EXPECTF--
Deprecated: The __wakeup() serialization magic method has been deprecated. Implement __unserialize() instead (or in addition, if support for old PHP versions is necessary) in %s on line %d
array(1) {
[0]=>
int(1)

View File

@@ -49,6 +49,10 @@ try {
?>
--EXPECTF--
Deprecated: The __wakeup() serialization magic method has been deprecated. Implement __unserialize() instead (or in addition, if support for old PHP versions is necessary) in %s on line %d
Deprecated: The __wakeup() serialization magic method has been deprecated. Implement __unserialize() instead (or in addition, if support for old PHP versions is necessary) in %s on line %d
Warning: unserialize(): Error at offset 17 of 24 bytes in %s on line %d
bool(false)

View File

@@ -15,4 +15,5 @@ var_dump(unserialize($poc));
?>
--EXPECTF--
Deprecated: The __wakeup() serialization magic method has been deprecated. Implement __unserialize() instead (or in addition, if support for old PHP versions is necessary) in %s on line %d
%s(73588229205)

View File

@@ -0,0 +1,24 @@
--TEST--
__wakeup() deprecation promoted to exception
--FILE--
<?php
set_error_handler(function ($errno, $errstr, $errfile, $errline) {
throw new ErrorException($errstr);
});
try {
eval(<<<'CODE'
class Test {
public function __wakeup() {
return;
}
}
CODE);
} catch (Throwable $e) {
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
?>
--EXPECT--
ErrorException: The __wakeup() serialization magic method has been deprecated. Implement __unserialize() instead (or in addition, if support for old PHP versions is necessary)

View File

@@ -0,0 +1,7 @@
<?php
class Test {
public function __wakeup() {
return;
}
}

View File

@@ -0,0 +1,18 @@
--TEST--
__wakeup() deprecation promoted to exception
--FILE--
<?php
set_error_handler(function ($errno, $errstr, $errfile, $errline) {
throw new ErrorException($errstr);
});
try {
require __DIR__ . '/wakeup_deprecation_promoted_exception2.inc';
} catch (Throwable $e) {
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
?>
--EXPECT--
ErrorException: The __wakeup() serialization magic method has been deprecated. Implement __unserialize() instead (or in addition, if support for old PHP versions is necessary)

View File

@@ -14,5 +14,7 @@ unserialize($poc);
?>
DONE
--EXPECTF--
Deprecated: The __wakeup() serialization magic method has been deprecated. Implement __unserialize() instead (or in addition, if support for old PHP versions is necessary) in %s on line %d
Warning: unserialize(): Error at offset 50 of 50 bytes in %s on line %d
DONE