Bug #70803 [NEW]: Serialization of same DateTime causes wrong serialized value
| From: | biozshock at gmail dot com | Date: | Tue, 27 Oct 2015 17:43:39 +0000 |
| Subject: | Bug #70803 [NEW]: Serialization of same DateTime causes wrong serialized value | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-196845@lists.php.net to get a copy of this message | ||
From: biozshock at gmail dot com
Operating system: Ubuntu LTS
PHP version: 5.5.30
Package: Class/Object related
Bug Type: Bug
Bug description:Serialization of same DateTime causes wrong serialized value
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
--
Edit bug report at https://bugs.php.net/bug.php?id=70803&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=70803&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=70803&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=70803&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=70803&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=70803&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=70803&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=70803&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=70803&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=70803&r=support
Expected behavior: https://bugs.php.net/fix.php?id=70803&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=70803&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=70803&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=70803&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=70803&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=70803&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=70803&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=70803&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=70803&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=70803&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=70803&r=mysqlcfg