ID: 20676 Updated by: [EMAIL PROTECTED] Reported By: [EMAIL PROTECTED] Status: Verified -Bug Type: Scripting Engine problem +Bug Type: Class/Object related Operating System: All PHP Version: 4.3.0-dev New Comment:
This shouldn't really part of the scripting engine bugs but addressed to the authors of serialize() and unserialize(). Re-classifying. Previous Comments: ------------------------------------------------------------------------ [2002-12-08 11:07:52] [EMAIL PROTECTED] the second script works, the first one doesn't work. They do the same thing but in a different way. It is why i think that there is a bug with the first one. ------------------------------------------------------------------------ [2002-12-08 11:04:33] [EMAIL PROTECTED] I get this output from your second script (using PHP 4.3.0-dev): START VALUE IN SET: 2 VALUE OUT SET: 2 What's the bug here?? ------------------------------------------------------------------------ [2002-11-27 09:46:29] [EMAIL PROTECTED] But why doesn'it work with this code: <?php class A { var $x=1; } function set(){ $a =& new A(); $a->x=2; $GLOBALS['ref'] =& $a; echo "VALUE IN SET: {$GLOBALS['ref']->x} \n"; } //$a destroyed. $GLOBALS['ref'] not. echo "START\n"; set(); echo "VALUE OUT SET: {$GLOBALS['ref']->x}\n"; ?> I really think that it's a bug ------------------------------------------------------------------------ [2002-11-27 09:32:28] [EMAIL PROTECTED] i thought that PHP count references on data before destroys it. This is not the case. This is why $GLOBALS['ref'] is null isn't it ? ------------------------------------------------------------------------ [2002-11-27 09:22:51] [EMAIL PROTECTED] I try to keep reference on all instances of a class. Even, unserialized one. <?php class A { var $x=1; function __wakeup(){ $GLOBALS['ref'] =& $this; } } function set(){ //Serialize information $a =& new A(); $a->x=2; $data = serialize($a); //Unserialize $b =& unserialize($data); // i try without '&' $result= $b === $GLOBALS['ref']; // $result == true; echo "VALUE IN SET: {$b->x} \n"; // Echo 2 } set(); echo "VALUE OUT SET: {$GLOBALS['ref']->x}\n"; //echo nothing, $GLOBALS['ref'] is now NULL ! ?> I have read all docs, my eyes burns me but i really cannot understand. I look in database too. ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=20676&edit=1