ID: 14266
Updated by: zimt
Reported By: [EMAIL PROTECTED]
Old Status: Open
Status: Bogus
Bug Type: Scripting Engine problem
Operating System: Debian Linux
PHP Version: 4.2.0-dev
New Comment:
Behaviour of Circular / Selfreferencing objects is not defined.
you could try to do a workarround
by using defining __sleep() and __wakeup()
in your class, which are called when the object is serialized / unserialized, and
could unset those self-references.
but you realy should do those.. if you dont destroy all of those references, you will
get memory leaks!
regards, Peter Petermann
Previous Comments:
------------------------------------------------------------------------
[2001-11-28 08:43:47] [EMAIL PROTECTED]
I dont' agree. Circular refferences can happen with
objects (using refferences). Sometimes they are
intentional. And serialize() doesn't completely ignore
this. Because it spits out:
O:8:"stdClass":1:{s:1:"x";O:8:"stdClass":1:{s:1:"x";R:2;}}
so it knows about circular refferences.
Now is there any reason why it doesn't generate instead
something like this:
O:8:"stdClass":1:{s:1:"x";R:1;}
I would understand if it completely ignores circular
references, but it doesn't. It just misbehaves.
------------------------------------------------------------------------
[2001-11-28 08:41:04] [EMAIL PROTECTED]
Your creating a reference to itself this is not allowed.
Therefore the bug is bogus, the behaviour is undefined.
- James
------------------------------------------------------------------------
[2001-11-28 08:38:38] [EMAIL PROTECTED]
Tested this with current cvs too. No better luck.
Original and unserialized objects have different
representation in memory.
------------------------------------------------------------------------
[2001-11-28 08:38:01] [EMAIL PROTECTED]
Circualar reference here:
$x->x =& $x;
These dont work as expected at all.
Bogus bug report as the lang isnt designed to support this.
- James
------------------------------------------------------------------------
[2001-11-28 08:32:48] [EMAIL PROTECTED]
Consider following simple script. It's pretty obvious
that serialize() does not work correctly (at least not as
expected).
<?php
$x = new stdClass();
$x->x =& $x;
$s = serialize($x) . "\n";
echo "test on original: "; // OK
$x->a = "str";
echo $x->x->a . "\n";
$o = unserialize($s);
echo "test on unserialized object: "; // not OK
$o->a = "str";
echo $o->x->a . "\n";
?>
------------------------------------------------------------------------
Edit this bug report at http://bugs.php.net/?id=14266&edit=1
--
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]