|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2018-12-15 08:50 UTC] sh at analogic dot cz
Description: ------------ See test script 5.6.38 - 7.2.13 will work OK 7.3.0 fails with "Notice: unserialize(): Error at offset 938 of 2517 bytes in /in/gTumn on line 3" (https://3v4l.org/gTumn) Object is serialized at PHP 7.3.0 Test script: --------------- <?php var_dump(unserialize('a:4:{i:0;O:20:"AppBundle\\Entity\\Box":18:{s:10:"' . "\0" . '*' . "\0" . 'address";s:13:"test@test.com";s:7:"' . "\0" . '*' . "\0" . 'user";s:4:"test";s:9:"' . "\0" . '*' . "\0" . 'domain";O:38:"Proxies\\__CG__\\AppBundle\\Entity\\Domain":10:{s:17:"__isInitialized__";b:1;s:7:"' . "\0" . '*' . "\0" . 'name";s:8:"test.com";s:10:"' . "\0" . '*' . "\0" . 'created";O:8:"DateTime":3:{s:4:"date";s:26:"2018-12-14 21:38:14.000000";s:13:"timezone_type";i:3;s:8:"timezone";s:3:"UTC";}s:10:"' . "\0" . '*' . "\0" . 'updated";O:8:"DateTime":3:{s:4:"date";s:26:"2018-12-14 21:38:14.000000";s:13:"timezone_type";i:3;s:8:"timezone";s:3:"UTC";}s:12:"' . "\0" . '*' . "\0" . 'domainBin";b:0;s:19:"' . "\0" . '*' . "\0" . 'domainBinAddress";N;s:10:"' . "\0" . '*' . "\0" . 'forward";b:0;s:16:"' . "\0" . '*' . "\0" . 'forwardDomain";N;s:14:"' . "\0" . '*' . "\0" . 'referenceId";N;s:8:"' . "\0" . '*' . "\0" . 'boxes";O:33:"Doctrine\\ORM\\PersistentCollection":2:{s:13:"' . "\0" . '*' . "\0" . 'collection";O:43:"Doctrine\\Common\\Collections\\ArrayCollection":1:{s:53:"' . "\0" . 'Doctrine\\Common\\Collections\\ArrayCollection' . "\0" . 'elements";a:1:{i:0;O:20:"AppBundle\\Entity\\Box":18:{s:10:"' . "\0" . '*' . "\0" . 'address";s:13:"test@test.com";s:7:"' . "\0" . '*' . "\0" . 'user";s:4:"test";s:9:"' . "\0" . '*' . "\0" . 'domain";r:6;s:11:"' . "\0" . '*' . "\0" . 'password";s:120:"{SHA512-CRYPT}$6$acvyLX2N9lsg1F.K$Bop/wS7UxWIH/VzR0uGhopOBSVvwlAdsdxzqXgwluo4VmylnzgGQ5/UhdHZ/1U0UyID8POk2/vGy2h4Q4pGSQ1";s:20:"' . "\0" . '*' . "\0" . 'passwordPlaintext";s:0:"";s:7:"' . "\0" . '*' . "\0" . 'home";s:27:"/data/domains/test.com/test";s:6:"' . "\0" . '*' . "\0" . 'uid";i:8;s:6:"' . "\0" . '*' . "\0" . 'gid";i:8;s:7:"' . "\0" . '*' . "\0" . 'name";s:0:"";s:11:"' . "\0" . '*' . "\0" . 'disabled";b:0;s:14:"' . "\0" . '*' . "\0" . 'domainAdmin";b:0;s:13:"' . "\0" . '*' . "\0" . 'superAdmin";b:1;s:21:"' . "\0" . '*' . "\0" . 'strictFromDisabled";b:0;s:14:"' . "\0" . '*' . "\0" . 'referenceId";N;s:10:"' . "\0" . '*' . "\0" . 'created";O:8:"DateTime":3:{s:4:"date";s:26:"2018-12-14 21:38:33.000000";s:13:"timezone_type";i:3;s:8:"timezone";s:3:"UTC";}s:10:"' . "\0" . '*' . "\0" . 'updated";O:8:"DateTime":3:{s:4:"date";s:26:"2018-12-14 21:39:41.000000";s:13:"timezone_type";i:3;s:8:"timezone";s:3:"UTC";}s:15:"' . "\0" . '*' . "\0" . 'redirectOnly";b:0;s:13:"' . "\0" . '*' . "\0" . 'redirectTo";a:0:{}}}}s:14:"' . "\0" . '*' . "\0" . 'initialized";b:1;}}s:11:"' . "\0" . '*' . "\0" . 'password";s:120:"{SHA512-CRYPT}$6$acvyLX2N9lsg1F.K$Bop/wS7UxWIH/VzR0uGhopOBSVvwlAdsdxzqXgwluo4VmylnzgGQ5/UhdHZ/1U0UyID8POk2/vGy2h4Q4pGSQ1";s:20:"' . "\0" . '*' . "\0" . 'passwordPlaintext";s:0:"";s:7:"' . "\0" . '*' . "\0" . 'home";s:27:"/data/domains/test.com/test";s:6:"' . "\0" . '*' . "\0" . 'uid";i:8;s:6:"' . "\0" . '*' . "\0" . 'gid";i:8;s:7:"' . "\0" . '*' . "\0" . 'name";s:0:"";s:11:"' . "\0" . '*' . "\0" . 'disabled";b:0;s:14:"' . "\0" . '*' . "\0" . 'domainAdmin";b:0;s:13:"' . "\0" . '*' . "\0" . 'superAdmin";b:1;s:21:"' . "\0" . '*' . "\0" . 'strictFromDisabled";b:0;s:14:"' . "\0" . '*' . "\0" . 'referenceId";N;s:10:"' . "\0" . '*' . "\0" . 'created";r:40;s:10:"' . "\0" . '*' . "\0" . 'updated";r:44;s:15:"' . "\0" . '*' . "\0" . 'redirectOnly";b:0;s:13:"' . "\0" . '*' . "\0" . 'redirectTo";a:0:{}}i:1;b:1;i:2;a:2:{i:0;O:41:"Symfony\\Component\\Security\\Core\\Role\\Role":1:{s:47:"' . "\0" . 'Symfony\\Component\\Security\\Core\\Role\\Role' . "\0" . 'role";s:9:"ROLE_USER";}i:1;O:41:"Symfony\\Component\\Security\\Core\\Role\\Role":1:{s:47:"' . "\0" . 'Symfony\\Component\\Security\\Core\\Role\\Role' . "\0" . 'role";s:16:"ROLE_SUPER_ADMIN";}}i:3;a:0:{}}')); Expected result: ---------------- Object is decoded and dumped Actual result: -------------- Notice: unserialize(): Error at offset 938 of 2517 bytes in /in/gTumn on line 3 PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Dec 05 02:00:01 2025 UTC |
This behavioral change has been introduced by commit f26fc52[1]. It doesn't appear that the former behavior was correct, though, since s:9:" * domain";r:6 has been unserialized as ["domain":protected] => bool(true) [1] <http://git.php.net/?p=php-src.git;a=commit;h=f26fc527da442943892f265ea48d94a22c29b2bc>The problem is caused by different order during serialisation and unserialization and therefore different reference numbering. This only happens when Serializable objects call serialize/unserialize functions few times. function serialize() { return serialize(array($this->data, parent::serialize())); } function unserialize($data) { list($this->$data, $parent_data) = unserialize($data); parent::unserialize($parent_data); } The problem can't be fixed without format change (e.g. we may use string position instead of object number). As a workaround, I propose avoiding nested serialization like parent::serialize() calls.