Bug #72971 [Opn->Csd]: SimpleXML isset/unset do not respect namespace

From: Date: Tue, 30 Aug 2016 08:57:11 +0000
Subject: Bug #72971 [Opn->Csd]: SimpleXML isset/unset do not respect namespace
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-203672@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=72971&edit=1

 ID:                 72971
 Updated by:         nikic@php.net
 Reported by:        nikic@php.net
 Summary:            SimpleXML isset/unset do not respect namespace
-Status:             Open
+Status:             Closed
 Type:               Bug
 Package:            SimpleXML related
 PHP Version:        Irrelevant
 Block user comment: N
 Private report:     N

 New Comment:

Automatic comment on behalf of nikic
Revision: http://git.php.net/?p=php-src.git;a=commit;h=07cc6a6ba2d8cebe2b375353491a26953b250149
Log: Fix bug #72971


Previous Comments:
------------------------------------------------------------------------
[2016-08-30 08:30:18] 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"
}


------------------------------------------------------------------------



--
Edit this bug report at https://bugs.php.net/bug.php?id=72971&edit=1


Thread (2 messages)

« previous php.bugs (#203672) next »