Object Equality

php.internals

Unnamed Person

22 years ago
(Note: this email seems to relate to this list in my opinion, but I have been chewed out before when posting such emails) I am using PHP 4.3.2, and it seems that testing objects for equality (with == or ===) causes an internal bug when the objects have recursive instance variables. That is, if the objects being tested have a variable that is a reference to an object that has a variable that is a reference to the first object, then the PHP processor dies. What can be done about this? If this needs to be sent to another mailing list, please let me know. Thank you.

Robert Cummings

22 years ago
On Wed, 2003-10-08 at 10:21, LingWitt@insightbb.com wrote:
> (Note: this email seems to relate to this list in my opinion, but I > have been chewed out before when posting such emails) > > I am using PHP 4.3.2, and it seems that testing objects for equality > (with == or ===) causes an internal bug when the objects have recursive > instance variables. That is, if the objects being tested have a > variable that is a reference to an object that has a variable that is a > reference to the first object, then the PHP processor dies. What can be > done about this? If this needs to be sent to another mailing list, > please let me know.
Dirty hack -- create a unique ID instance variable for objects via their constructor. Implement equality check with: if( $obj1->uid == $obj2->uid ) { // Same object, yaaaaaaaaaaay! } Cheers, Rob.
-- .------------------------------------------------------------. | InterJinn Application Framework - http://www.interjinn.com | :------------------------------------------------------------: | An application and templating framework for PHP. Boasting | | a powerful, scalable system for accessing system services | | such as forms, properties, sessions, and caches. InterJinn | | also provides an extremely flexible architecture for | | creating re-usable components quickly and easily. | `------------------------------------------------------------'

Wez Furlong

22 years ago
Interestingly enough, I brought up this issue just over a year ago. Even more interesting is that I stumbled across my original post from that time while looking into something else today. http://news.php.net/article.php?group=php.dev&article=88735 (patch included) --Wez. ----- Original Message ----- From: <LingWitt@insightbb.com> To: <internals@lists.php.net> Sent: Wednesday, October 08, 2003 3:21 PM Subject: [PHP-DEV] Object Equality

Andi Gutmans

22 years ago
Hi Wez, Your patch breaks BC in 4.3.x. As the problem has been solved in PHP 5, I suggest we don't add the patch and wait for the major version to break BC (very slightly). Andi At 03:42 PM 10/9/2003 +0100, Wez Furlong wrote:

Wez Furlong

22 years ago
Agreed. --Wez.