From:             [EMAIL PROTECTED]
Operating system: Windows XP, Linux
PHP version:      4.2.3
PHP Bug Type:     Class/Object related
Bug description:  Serialization of objects with references is redundant

<?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 bug report at http://bugs.php.net/?id=21059&edit=1
-- 
Try a CVS snapshot:         http://bugs.php.net/fix.php?id=21059&r=trysnapshot
Fixed in CVS:               http://bugs.php.net/fix.php?id=21059&r=fixedcvs
Fixed in release:           http://bugs.php.net/fix.php?id=21059&r=alreadyfixed
Need backtrace:             http://bugs.php.net/fix.php?id=21059&r=needtrace
Try newer version:          http://bugs.php.net/fix.php?id=21059&r=oldversion
Not developer issue:        http://bugs.php.net/fix.php?id=21059&r=support
Expected behavior:          http://bugs.php.net/fix.php?id=21059&r=notwrong
Not enough info:            http://bugs.php.net/fix.php?id=21059&r=notenoughinfo
Submitted twice:            http://bugs.php.net/fix.php?id=21059&r=submittedtwice
register_globals:           http://bugs.php.net/fix.php?id=21059&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=21059&r=php3
Daylight Savings:           http://bugs.php.net/fix.php?id=21059&r=dst
IIS Stability:              http://bugs.php.net/fix.php?id=21059&r=isapi

Reply via email to