SimpleXML element comparison is broken
Nobody has claimed this yet.
- Dominant language
- C
- Stars
- 40.4k
- Forks
- 8.1k
- Avg merge
- 2d 13h
- Merged PRs (30d)
- 96
Description
Description
The following code:
<?php
$xml = "<root><first/><second/><third/></root>";
$xml = simplexml_load_string($xml);
var_dump($xml->first == $xml->second);
Resulted in this output:
bool(true)
But I expected this output instead:
bool(false)
It's because the wrong node is fetched, i.e. it doesn't take into account the iterating nature of the simple xml objects. PoC fix patch (needs more testing and thinking): https://gist.github.com/nielsdos/f8e232836d72e68c5d3418116ddad877
PHP Version
PHP 5.0.0-master
Operating System
Linux
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by running the SimpleXML reproducer from the issue and trace how comparison of $xml->first and $xml->second selects nodes. Use the linked PoC patch as context, then verify that the same example reports bool(false) and check related SimpleXML comparison behavior for regressions.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100