Edit report at https://bugs.php.net/bug.php?id=55801&edit=1
ID: 55801 Updated by: paj...@php.net Reported by: mapi at pdepend dot org Summary: Behavior of unserialize has changed Status: Feedback Type: Bug Package: Variables related Operating System: Linux (Fedora 15) PHP Version: 5.4.0beta1 Block user comment: N Private report: N New Comment: Hm, hard to find what failed without an example then. Can you try to create a script to generate an object tree and un/serialize it? That will be very helpful to fix this problem. Previous Comments: ------------------------------------------------------------------------ [2011-09-28 08:50:27] mapi at pdepend dot org What PHP_Depend does is serializing double linked object trees like. It uses __sleep() to reset the child-parent link before a tree gets serialized: class Node { protected $parent; protected $nodes = array(); public function __sleep() { return array('nodes'); } } And it uses __wakeup() to restore this link during the unserialization: class Node { protected $parent; protected $nodes = array(); public function __sleep() { return array('nodes'); } public function __wakeup() { foreach ($this->nodes as $node) { $node->parent = $this; } } } Now it seems that under certain circumstances the $this->nodes property is an array when __wakeup() is called, but instead of objects the array values are NULL. This happens when the following PHP Warning occurs: PHP Warning: Creating default object from empty value in /tmp/pdepend/src/main/php/PHP/Depend/Code/ASTNode.php on line 569 ------------------------------------------------------------------------ [2011-09-28 08:36:08] mapi at pdepend dot org No it's about large object trees serialized in PHP 5.4 and unserialized with the same version. This has worked with all PHP versions < 5.4. It seems that these object trees are now unserialized or serialized or destructed in a different order, so that some of the previous objects are now NULL. ------------------------------------------------------------------------ [2011-09-27 20:16:39] paj...@php.net Is it about objects being serialized and stored using 5.3 and unserialized using 5.4? And it fails to unserialize them? Or are you doing this proecess manually? ------------------------------------------------------------------------ [2011-09-27 20:06:13] mapi at pdepend dot org Description: ------------ There is a regression or change in how object structures are serialized or unserialized in PHP's 5.4.x branch. I am sorry that I cannot give a more detailed explanation and say what has changed and causes this issue, but an object cache for one of my applications fails with all PHP 5.4.x version, while it works with all PHP 5.2.x and PHP 5.3.x versions. I would expect that this behavior change would also affect other applications or libraries that utilize PHP's (un)serialize functions. Test script: --------------- #!/bin/sh PHP_BIN=/usr/local/bin/php540 cd /tmp git clone https://github.com/pdepend/pdepend.git cd pdepend "$PHP_BIN" ./src/bin/pdepend.php --summary-xml=sum.xml src/main/ "$PHP_BIN" ./src/bin/pdepend.php --summary-xml=sum.xml src/main/ Expected result: ---------------- PHP_Depend @package_version@ by Manuel Pichler Parsing source files: ............................................................ 60 ............................................................ 120 ............................................................ 180 ................ 196 Executing CyclomaticComplexity-Analyzer: ............................................................ 1200 .............................. 1818 Executing ClassLevel-Analyzer: ............................................................ 1200 ...................... 1647 Executing CodeRank-Analyzer: .......... 217 Executing Coupling-Analyzer: ............................................................ 1200 .......................................... 2048 Executing Hierarchy-Analyzer: ............................................................ 1200 ................................ 1852 Executing Inheritance-Analyzer: ........................... 549 Executing NPathComplexity-Analyzer: ............................................................ 1200 ............................... 1830 Executing NodeCount-Analyzer: ............................................................ 1200 .................. 1564 Executing NodeLoc-Analyzer: ............................................................ 1200 ............................ 1766 Generating pdepend log files, this may take a moment. 00:16; Memory: 124.00Mb Actual result: -------------- PHP_Depend @package_version@ by Manuel Pichler Parsing source files: ............................................................ 60 ............................................................ 120 .................PHP Warning: Creating default object from empty value in /tmp/pdepend/src/main/php/PHP/Depend/Code/ASTNode.php on line 569 Warning: Creating default object from empty value in /tmp/pdepend/src/main/php/PHP/Depend/Code/ASTNode.php on line 569 .........................PHP Warning: Creating default object from empty value in /tmp/pdepend/src/main/php/PHP/Depend/Code/ASTNode.php on line 569 Warning: Creating default object from empty value in /tmp/pdepend/src/main/php/PHP/Depend/Code/ASTNode.php on line 569 .........PHP Warning: Creating default object from empty value in /tmp/pdepend/src/main/php/PHP/Depend/Code/ASTNode.php on line 569 Warning: Creating default object from empty value in /tmp/pdepend/src/main/php/PHP/Depend/Code/ASTNode.php on line 569 PHP Warning: Creating default object from empty value in /tmp/pdepend/src/main/php/PHP/Depend/Code/ASTNode.php on line 569 Warning: Creating default object from empty value in /tmp/pdepend/src/main/php/PHP/Depend/Code/ASTNode.php on line 569 PHP Warning: Creating default object from empty value in /tmp/pdepend/src/main/php/PHP/Depend/Code/ASTNode.php on line 569 Warning: Creating default object from empty value in /tmp/pdepend/src/main/php/PHP/Depend/Code/ASTNode.php on line 569 ......... 180 ...........PHP Warning: Creating default object from empty value in /tmp/pdepend/src/main/php/PHP/Depend/Code/ASTNode.php on line 569 Warning: Creating default object from empty value in /tmp/pdepend/src/main/php/PHP/Depend/Code/ASTNode.php on line 569 ..... 196 Executing CyclomaticComplexity-Analyzer: ....................PHP Fatal error: Call to a member function findChildrenOfType() on a non-object in /tmp/pdepend/src/main/php/PHP/Depend/Code/AbstractClassOrInterface.php on line 268 Fatal error: Call to a member function findChildrenOfType() on a non-object in /tmp/pdepend/src/main/php/PHP/Depend/Code/AbstractClassOrInterface.php on line 268 ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=55801&edit=1