Edit report at https://bugs.php.net/bug.php?id=55801&edit=1

 ID:                 55801
 Comment by:         mapi at pdepend dot org
 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:

Yes, here you can get the two serialized object structures:

http://manuel-pichler.de/stuff/5.3.ser
http://manuel-pichler.de/stuff/5.4.ser

And there is the difference:

5.3 -> *nodes";a:1:{i:0;r:18;}}}}}}}}}
5.4 -> *nodes";a:1:{i:0;r:36;}}}}}}}}}

It references something different.


Previous Comments:
------------------------------------------------------------------------
[2011-09-28 13:41:54] paj...@php.net

Any chance to get something that shows us the serialized data with 5.4 and 5.4 
so 
we can see how they differ?

Maybe upload the small possible code somewhere?

------------------------------------------------------------------------
[2011-09-28 13:30:46] mapi at pdepend dot org

Okay, I tried for several hours to create a reproducable outside of 
PHP_Depend's 
context, but I cannot reproduce this behavior :(

But at least I came up with a small code fragement that illustrates this 
behavior:

  <?php
  class Test {
      function method() {   
          $this->prop[$y]++;
      }
  }

which was translated into the following object graph:

 Statement
   Expression
     MemberPrimaryPrefix  <----------
       Variable                     |
       PropertyPostfix              |
         ArrayIndexExpression  [Same Instance]
           Identifier               |
           Variable                 |
     PostfixExpression              |
       MemberPrimaryPrefix ----------
         Variable
         PropertyPostfix
           ArrayIndexExpression
             Identifier
             Variable

And this second reference to MemberPrimaryPrefix is NULL after unserialization 
with PHP 5.4 and it is just a second clone with PHP < 5.4

------------------------------------------------------------------------
[2011-09-28 08:56:52] mapi at pdepend dot org

I will try to create a reproducable.

------------------------------------------------------------------------
[2011-09-28 08:51:38] paj...@php.net

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.

------------------------------------------------------------------------
[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

------------------------------------------------------------------------


The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at

    https://bugs.php.net/bug.php?id=55801


-- 
Edit this bug report at https://bugs.php.net/bug.php?id=55801&edit=1

Reply via email to