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: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: nikic@php.net
New email:
PHP Version: OS:

 

 [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

Pull Requests

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-2025 The PHP Group
All rights reserved.
Last updated: Sun Feb 02 03:01:31 2025 UTC