Bug #72971 [NEW]: SimpleXML isset/unset do not respect namespace
From: nikic
Operating system:
PHP version: Irrelevant
Package: SimpleXML related
Bug Type: Bug
Bug description:SimpleXML isset/unset do not respect namespace
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 bug report at https://bugs.php.net/bug.php?id=72971&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=72971&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=72971&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=72971&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=72971&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=72971&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=72971&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=72971&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=72971&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=72971&r=support
Expected behavior: https://bugs.php.net/fix.php?id=72971&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=72971&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=72971&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=72971&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=72971&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=72971&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=72971&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=72971&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=72971&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=72971&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=72971&r=mysqlcfg
Thread (2 messages)
- nikic@php.net