#21059 [Com]: Serialization of objects with references is redundant
| From: | milan at acmilan dot hu | Date: | Tue, 17 Dec 2002 18:00:08 +0000 |
| Subject: | #21059 [Com]: Serialization of objects with references is redundant | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-27938@lists.php.net to get a copy of this message | ||
ID: 21059
Comment by: milan@acmilan.hu
Reported By: milan@acmilan.hu
Status: Open
Bug Type: Class/Object related
Operating System: Windows XP, Linux
PHP Version: 4.2.3
New Comment:
here's the output of the script:
http://maldini.dyndns.org/~milan/bug.php
Previous Comments:
------------------------------------------------------------------------
[2002-12-16 20:23:58] milan@acmilan.hu
<?PHP
class A
{
var $Text;
var $Parent;
function A(&$parent, $s)
{
$this->Text = $s;
$this->Parent = &$parent;
}
}
class B
{
var $Child;
function B()
{
$this->Child =& new A($this, "Hello");
}
}
class C
{
var $Child;
function C()
{
$this->Child = new A($this, "Hello");
}
}
echo "<pre>\n\n";
$b= new B();
$s = serialize($b);
echo "$s\n" . strlen($s) . "\n";
$s = serialize(&$b);
echo "$s\n" . strlen($s) . "\n";
$b=& new B();
$s = serialize($b);
echo "$s\n" . strlen($s) . "\n";
$s = serialize(&$b);
echo "$s\n" . strlen($s) . "\n";
$c= new C();
$s = serialize($c);
echo "$s\n" . strlen($s) . "\n";
$c=& new C();
$s = serialize(&$c);
echo "$s\n" . strlen($s) . "\n";
echo "</pre>";
?>
-------cut-----------
hello! i tried this script both on windows and linux with PHP 4.2.3
installed. I saw, that the serialized code could be highly redundant,
depending on serializing the object or it's refference. there's also a
problem around the new constructor, or i guess, the problem might be at
copying objects with the '=' operator...
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=21059&edit=1