ID:               46140
 Updated by:       [EMAIL PROTECTED]
 Reported By:      ehassler at synapsestudios dot com
-Status:           Open
+Status:           Feedback
 Bug Type:         Class/Object related
 Operating System: *
 PHP Version:      5.2.6
 New Comment:

Please try using this CVS snapshot:

  http://snaps.php.net/php5.2-latest.tar.gz
 
For Windows:

  http://windows.php.net/snapshots/




Previous Comments:
------------------------------------------------------------------------

[2008-09-21 02:33:42] ehassler at synapsestudios dot com

After adding static $instance2 to class C, and changing the __wakeup to
this:

function __wakeup()
{
        if($this->value instanceof C)
        {
                C::$instance2 = $this->value;
                $this->value = C::$instance;
        }
}

I get the expected behavior.  So, I guess, you know, hope that helps.

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

[2008-09-21 02:22:58] ehassler at synapsestudios dot com

Description:
------------
During unserialization of a 3 deep non-recursive but not-a-tree data
structure (more like a diamond) where, on nodes in level 2 a __wakeup
causes all references to a child node of a certain class to be removed,
when that child node would occur in subsequent level 2 nodes' child
spots, the reference instead now points to the next level 2 node instead
of any level 3 node.  More specifically, it points to the first level 2
node after the one that removed said child.

The sample code makes it more clear.

Reproduce code:
---------------
        class B {
                public $value;
                function __construct($value){ $this->value = $value; }
                
                function __wakeup()
                {
                        if($this->value instanceof C)
                                        $this->value = C::$instance;
                }
        }
        
        class C { static public $instance; }
        
        C::$instance = new C;
        
        $A = array(  new B(C::$instance), new B(C::$instance), new
B(C::$instance) );      

        var_dump($A);
        $A = unserialize(serialize($A));
        var_dump($A);

Expected result:
----------------
array
  0 => 
    object(B)[2]
      public 'value' => 
        object(C)[1]
  1 => 
    object(B)[3]
      public 'value' => 
        object(C)[1]
  2 => 
    object(B)[4]
      public 'value' => 
        object(C)[1]

array
  0 => 
    object(B)[5]
      public 'value' => 
        object(C)[1]
  1 => 
    object(B)[7]
      public 'value' => 
        object(C)[1]
  2 => 
    object(B)[8]
      public 'value' => 
        object(C)[1]


Actual result:
--------------
array
  0 => 
    object(B)[2]
      public 'value' => 
        object(C)[1]
  1 => 
    object(B)[3]
      public 'value' => 
        object(C)[1]
  2 => 
    object(B)[4]
      public 'value' => 
        object(C)[1]

array
  0 => 
    object(B)[5]
      public 'value' => 
        object(C)[1]
  1 => 
    object(B)[6]
      public 'value' => 
        &object(B)[6]
  2 => 
    object(B)[7]
      public 'value' => 
        object(B)[6]
          public 'value' => 
            &object(B)[6]



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


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

Reply via email to