#45299 [Opn->Fbk]: serialize / unserialize $GLOBALS breaks global objects
| From: | jani@php.net | Date: | Thu, 03 Jul 2008 11:53:03 +0000 |
| Subject: | #45299 [Opn->Fbk]: serialize / unserialize $GLOBALS breaks global objects | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-126234@lists.php.net to get a copy of this message | ||
ID: 45299
Updated by: jani@php.net
Reported By: taco at procurios dot nl
-Status: Open
+Status: Feedback
Bug Type: Class/Object related
Operating System: linux
PHP Version: 5.2.6
New Comment:
Please tell us WHY do you want to serialize special super global arrays
like $GLOBALS in the first place?! That's propably the dummiest idea
ever..
Previous Comments:
------------------------------------------------------------------------
[2008-06-18 12:03:24] taco at procurios dot nl
Description:
------------
When serializing and later on deserializing the $GLOBALS array, global
objects aren't recreated.
Reproduce code:
---------------
class Foo
{
public $foo;
public function __construct($foo)
{
$this->foo = $foo;
}
}
$Foo = new Foo(34);
var_dump($GLOBALS['Foo']);
$s = serialize($GLOBALS);
$GLOBALS = unserialize($s);
var_dump($GLOBALS['Foo']);
Expected result:
----------------
object(Foo)#1 (1) {
["foo"]=>
int(34)
}
object(Foo)#1 (1) {
["foo"]=>
int(34)
}
Actual result:
--------------
object(Foo)#1 (1) {
["foo"]=>
int(34)
}
int(1)
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=45299&edit=1