Bug #13968 Updated: $this reference is bad during __wakeup

From: Date: Wed, 12 Dec 2001 19:27:42 +0000
Subject: Bug #13968 Updated: $this reference is bad during __wakeup
References: 1  Groups: php.dev 
Request: Send a blank email to php-dev+get-73373@lists.php.net to get a copy of this message
ID: 13968
Updated by: zak
Reported By: david@php.net
Status: Feedback
Bug Type: Scripting Engine problem
Operating System: Debian Linux
PHP Version: 4.0.6
New Comment:

Thies has made changes to how serialize handles 
references. The changes are incorporated in PHP 4.1.0 
Upgrading may fix your problem.


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

[2001-12-12 07:45:46] yohgaki@php.net

Any update for this bug?

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

[2001-11-06 22:56:04] david@php.net

References to $this are randomly wrong during __wakeup.
I am keeping track of all objects in a global $objs.

global $objs;
$objs[] =& $this;

during __wakeup causes $objs[] to gain an element that matches some random OTHER variable in my
script (an integer I was using somewhere, or an array I had somewhere else)

Unforunately I cannot reproduce this on a simple script, but here is the essence of what I am doing:

<?
$objs = array();

class O {
  function __wakeup() {
    global $objs;
    $objs[] =& $this;
  }
}

class X extends O {
  var $a = 213;
  var $b = 'hello';
}

$x = new X();
$y = serialize($x);
$z = unserialize($y);

var_dump($objs);
?>

^^ the above script works perfectly, but in a more complex script doing the same thing, it ends up
putting a reference to a totally different variable into $objs.

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



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



Thread (4 messages)

« previous php.dev (#73373) next »