|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2017-01-01 12:32 UTC] nikic@php.net
-Status: Open
+Status: Duplicate
[2017-01-01 12:32 UTC] nikic@php.net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Nov 01 19:00:02 2025 UTC |
Description: ------------ If class implements \Serializable interface and serializes same instance of \DateTime object - deserialization fails with Notice: Notice: unserialize(): Error at offset 13 of 157 bytes in /opt/project/testme.php on line 12 Test script: --------------- class A implements \Serializable { public function serialize() { $dt = new \DateTime(); return serialize(array($dt, serialize([$dt]))); } public function unserialize($serialized) { $a = unserialize($serialized); unserialize($a[1]); } } $a = new A(); $s = serialize($a); $d = unserialize($s); Expected result: ---------------- Empty screen, no notices and proper de-serialized value Actual result: -------------- Notice: unserialize(): Error at offset 13 of 157 bytes in /opt/project/testme.php on line 12 And properly deserialized \DateTime object