#43395 [Opn->Bgs]: unserialize reinitialize unsetted object's properties
| From: | jani@php.net | Date: | Sat, 24 Nov 2007 12:11:35 +0000 |
| Subject: | #43395 [Opn->Bgs]: unserialize reinitialize unsetted object's properties | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-120006@lists.php.net to get a copy of this message | ||
ID: 43395
Updated by: jani@php.net
Reported By: ramdac at sweetorange dot it
-Status: Open
+Status: Bogus
Bug Type: Scripting Engine problem
Operating System: Linux 2.6.20-16-generic
PHP Version: 5.2.5
New Comment:
Of course it is set, unserialize() process uses the class definition
for re-creating the object. And as your class has the default value, of
course it will be re-created.
See also:
http://fi2.php.net/manual/en/language.oop.serialization.php
Previous Comments:
------------------------------------------------------------------------
[2007-11-24 11:58:25] ramdac at sweetorange dot it
Description:
------------
If I unset an object property, after serialize/unserialize the property
is re-initialized with default value defined in class declaration.
Reproduce code:
---------------
class test
{
public $testUnset = 'default value';
}
$o = new test();
var_dump($o);
unset($o->testUnset);
var_dump($o);
$s = serialize($o);
$oo = unserialize($s);
var_dump($oo);
Expected result:
----------------
object(test)#1 (1) {
["testUnset"]=>
string(13) "default value"
}
object(test)#1 (0) {
}
object(test)#2 (1) {
}
Actual result:
--------------
object(test)#1 (1) {
["testUnset"]=>
string(13) "default value"
}
object(test)#1 (0) {
}
object(test)#2 (1) {
["testUnset"]=>
string(13) "default value"
}
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=43395&edit=1