php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #72971 SimpleXML isset/unset do not respect namespace
Submitted: 2016-08-30 08:30 UTC Modified: -
From: nikic@php.net Assigned:
Status: Closed Package: SimpleXML related
PHP Version: Irrelevant OS:
Private report: No CVE-ID:
 [2016-08-30 08:30 UTC] nikic@php.net
Description:
------------
isset() and unset() on SimpleXML properties do not take the element namespace into account. isset() returns true if there is an element with that name in *any* namespace and unset() removes the property from *all* namespaces.

Test script:
---------------
<?php

$xml = new SimpleXMLElement('<root xmlns:ns="ns"><foo>bar</foo><ns:foo>ns:bar</ns:foo><ns:foo2>ns:bar2</ns:foo2></root>');
var_dump(isset($xml->foo2));
unset($xml->foo);
var_dump($xml->children('ns'));

Expected result:
----------------
bool(false)
object(SimpleXMLElement)#2 (2) {
  ["foo"]=>
  string(6) "ns:bar"
  ["foo2"]=>
  string(7) "ns:bar2"
}

Actual result:
--------------
bool(true)
object(SimpleXMLElement)#2 (1) {
  ["foo2"]=>
  string(7) "ns:bar2"
}

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2016-08-30 08:57 UTC] nikic@php.net
Automatic comment on behalf of nikic
Revision: http://git.php.net/?p=php-src.git;a=commit;h=07cc6a6ba2d8cebe2b375353491a26953b250149
Log: Fix bug #72971
 [2016-08-30 08:57 UTC] nikic@php.net
-Status: Open +Status: Closed
 [2016-10-17 10:08 UTC] bwoebi@php.net
Automatic comment on behalf of nikic
Revision: http://git.php.net/?p=php-src.git;a=commit;h=07cc6a6ba2d8cebe2b375353491a26953b250149
Log: Fix bug #72971
 
PHP Copyright © 2001-2017 The PHP Group
All rights reserved.
Last updated: Tue Aug 29 15:01:52 2017 UTC