Bug #75965 [NEW]: DateTimeZone object has not been correctly initialized after unserialization
| From: | ivan at podorozhny dot ru | Date: | Thu, 15 Feb 2018 14:33:06 +0000 |
| Subject: | Bug #75965 [NEW]: DateTimeZone object has not been correctly initialized after unserialization | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-213972@lists.php.net to get a copy of this message | ||
From: ivan at podorozhny dot ru
Operating system: Ubuntu 16.04.3 LTS 4.4.0-28-gene
PHP version: 7.1.14
Package: *General Issues
Bug Type: Bug
Bug description:DateTimeZone object has not been correctly initialized after unserialization
Description:
------------
PHP 7.1.6-1~ubuntu16.04.1+deb.sury.org+1 (cli) (built: Jun 9 2017
08:26:34) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2017 Zend Technologies
with Zend OPcache v7.1.6-1~ubuntu16.04.1+deb.sury.org+1, Copyright
(c) 1999-2017, by Zend Technologies
with Xdebug v2.5.5, Copyright (c) 2002-2017, by Derick Rethans
Test script:
---------------
class Foobar implements \Serializable
{
/** @return string */
public function serialize(): string
{
return serialize(new \DateTimeZone('Europe/Andorra'));
}
/** @param string $serialized */
public function unserialize($serialized)
{
var_dump($serialized);
var_dump(unserialize($serialized)->getName());
}
}
(new Foobar())->unserialize((new Foobar())->serialize());
var_dump(unserialize(serialize(new Foobar())));
Expected result:
----------------
The DateTimeZone object correct initialization
Actual result:
--------------
/tmp/test.php:14:
string(86)
"O:12:"DateTimeZone":2:{s:13:"timezone_type";i:3;s:8:"timezone";s:14:"Europe/Andorra";}"
/tmp/test.php:15:
string(14) "Europe/Andorra"
/tmp/test.php:14:
string(86)
"O:12:"DateTimeZone":2:{s:13:"timezone_type";i:3;s:8:"timezone";s:14:"Europe/Andorra";}"
PHP Warning: DateTimeZone::getName(): The DateTimeZone object has not
been correctly initialized by its constructor in /tmp/test.php on line
15
PHP Stack trace:
PHP 1. {main}() /tmp/test.php:0
PHP 2. unserialize() /tmp/test.php:20
PHP 3. Foobar->unserialize() /tmp/test.php:20
PHP 4. DateTimeZone->getName() /tmp/test.php:15
/tmp/test.php:15:
bool(false)
/tmp/test.php:20:
class Foobar#1 (0) {
}
--
Edit bug report at https://bugs.php.net/bug.php?id=75965&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=75965&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=75965&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=75965&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=75965&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=75965&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=75965&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=75965&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=75965&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=75965&r=support
Expected behavior: https://bugs.php.net/fix.php?id=75965&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=75965&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=75965&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=75965&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=75965&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=75965&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=75965&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=75965&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=75965&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=75965&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=75965&r=mysqlcfg