From:             phpbugs at steve dot ipapp dot com
Operating system: ANY
PHP version:      5.2.5
PHP Bug Type:     SimpleXML related
Bug description:  Broken Compatibility 

Description:
------------
In PHP 5.0.x and 5.1.x two SimpleXMLElement objects were considered equal
if they represented the same data.

In PHP 5.2.x this does not seem to be the case anymore. This was
previously listed as bug 39866 [http://bugs.php.net/bug.php?id=39866], but
for some reason this was listed as bogus.  In that bug it was noted that we
should look at Example 5 at http://php.net/simplexml. I'm assuming this is
Example 6 now [Comparing Elements and Attributes with Text] , but this is
incorrect as comparision will implicity cast 
it to string anyway.

According to
http://www.php.net/manual/en/language.oop5.object-comparison.php:
"When using the comparison operator (==), object variables are compared in
a simple manner, namely: Two object instances are equal if they have the
same attributes and values, and are instances of the same class... On the
other hand, when using the identity operator (===), object variables are
identical if and only if they refer to the same instance of the same
class." 

Furthermore this backwards incompatible change is not listed in :
http://us.php.net/manual/en/migration52.incompatible.php.

Currently there is no equals method that we can call to get the previous
functionality back, and at the present moment this makes == no longer
transitive as  especially since this makes == no longer transitive as 'doc'
== x1, 'doc' == x2, but x1 != x2. 

I do not understand why ==, nor do I see value in, doing a strict
comparison for SimpleXMLObjects as ==, when according to the PHP Object
Comparison manual this should be ===. 

Therefore I believe this is a bug.




Reproduce code:
---------------
$xmldoc = "<xml><value>foo</value></xml>";

$sax1 = new SimpleXMLElement("$xmldoc");
$sax2 = new SimpleXMLElement("$xmldoc");

if($sax1 == $sax2)
{
        echo "TRUE";
} else
{
        echo "FALSE";
}
echo "\n\n\n";


Expected result:
----------------
TRUE

Actual result:
--------------
FALSE

-- 
Edit bug report at http://bugs.php.net/?id=44411&edit=1
-- 
Try a CVS snapshot (PHP 5.2): 
http://bugs.php.net/fix.php?id=44411&r=trysnapshot52
Try a CVS snapshot (PHP 5.3): 
http://bugs.php.net/fix.php?id=44411&r=trysnapshot53
Try a CVS snapshot (PHP 6.0): 
http://bugs.php.net/fix.php?id=44411&r=trysnapshot60
Fixed in CVS:                 http://bugs.php.net/fix.php?id=44411&r=fixedcvs
Fixed in release:             
http://bugs.php.net/fix.php?id=44411&r=alreadyfixed
Need backtrace:               http://bugs.php.net/fix.php?id=44411&r=needtrace
Need Reproduce Script:        http://bugs.php.net/fix.php?id=44411&r=needscript
Try newer version:            http://bugs.php.net/fix.php?id=44411&r=oldversion
Not developer issue:          http://bugs.php.net/fix.php?id=44411&r=support
Expected behavior:            http://bugs.php.net/fix.php?id=44411&r=notwrong
Not enough info:              
http://bugs.php.net/fix.php?id=44411&r=notenoughinfo
Submitted twice:              
http://bugs.php.net/fix.php?id=44411&r=submittedtwice
register_globals:             http://bugs.php.net/fix.php?id=44411&r=globals
PHP 4 support discontinued:   http://bugs.php.net/fix.php?id=44411&r=php4
Daylight Savings:             http://bugs.php.net/fix.php?id=44411&r=dst
IIS Stability:                http://bugs.php.net/fix.php?id=44411&r=isapi
Install GNU Sed:              http://bugs.php.net/fix.php?id=44411&r=gnused
Floating point limitations:   http://bugs.php.net/fix.php?id=44411&r=float
No Zend Extensions:           http://bugs.php.net/fix.php?id=44411&r=nozend
MySQL Configuration Error:    http://bugs.php.net/fix.php?id=44411&r=mysqlcfg

Reply via email to