php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #13968 $this reference is bad during __wakeup
Submitted: 2001-11-06 22:56 UTC Modified: 2002-01-02 14:04 UTC
From: david@php.net Assigned:
Status: Closed Package: Scripting Engine problem
PHP Version: 4.0.6 OS: Debian Linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: david@php.net
New email:
PHP Version: OS:

 

 [2001-11-06 22:56 UTC] 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.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-12-12 07:45 UTC] yohgaki@php.net
Any update for this bug?
 [2001-12-12 14:27 UTC] zak@php.net
Thies has made changes to how serialize handles 
references. The changes are incorporated in PHP 4.1.0 
Upgrading may fix your problem.

 [2002-01-02 14:04 UTC] lobbin@php.net
No feedback. Closing.
 
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Wed Jan 29 14:01:24 2020 UTC