Skip to content

SimpleXML element comparison is broken #12171

Open
@nielsdos

Description

@nielsdos

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions