1
0
mirror of https://github.com/php/php-src.git synced 2026-04-27 18:23:26 +02:00
Files
archived-php-src/ext/standard/tests/serialize/bug80411.phpt
T
Jeremy Mikola 858d0c0916 Include class name in Serializable deprecation message
The deprecation message was originally introduced in 3e6b447 (#6494).

I first encountered this notice when testing the MongoDB extension
with PHP 8.1, which produced many duplicate messages that provided
no detail about the particular class that needed to be fixed.

Closes GH-7346.
2021-08-11 10:35:47 +02:00

33 lines
771 B
PHP

--TEST--
Bug #80411: References to null-serialized object break serialize()
--FILE--
<?php
class UnSerializable implements Serializable
{
public function serialize() {}
public function unserialize($serialized) {}
}
$unser = new UnSerializable();
$arr = [$unser];
$arr[1] = &$arr[0];
$arr[2] = 'endcap';
$arr[3] = &$arr[2];
$data = serialize($arr);
echo $data . PHP_EOL;
$recovered = unserialize($data);
var_export($recovered);
?>
--EXPECTF--
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
a:4:{i:0;N;i:1;N;i:2;s:6:"endcap";i:3;R:4;}
array (
0 => NULL,
1 => NULL,
2 => 'endcap',
3 => 'endcap',
)