Bug #75168 [NEW]: Unexpected PHP Warning Node no longer exists
| From: | goetas at gmail dot com | Date: | Thu, 07 Sep 2017 12:33:54 +0000 |
| Subject: | Bug #75168 [NEW]: Unexpected PHP Warning Node no longer exists | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-210993@lists.php.net to get a copy of this message | ||
From: goetas at gmail dot com
Operating system: any
PHP version: 7.0.23
Package: SimpleXML related
Bug Type: Bug
Bug description:Unexpected PHP Warning Node no longer exists
Description:
------------
currently the simplexml api exposes the SimpleXMLElement class when
asking elements that does not exists in the XML dom, but some operations
are inconsistent.
$xml // instanceof \SimpleXMLElement
$node = $xml->NOT_EXISTING_NODE_NAME; // instanceof \SimpleXMLElement
$a = $node->attributes() // instanceof \SimpleXMLElement
$b = $node->children() // instanceof \SimpleXMLElement
$a->asXML() // works
$a->count() // error
$a->getName() // does not work
// all the other method call will trigger the error
Test script:
---------------
<?php
$xml = simplexml_load_string('<root/>');
var_dump($xml->NOT_EXISTING_NODE_NAME instanceof \SimpleXMLElement);
$attributes = $xml->NOT_EXISTING_NODE_NAME->attributes();
var_dump(count($attributes));
Expected result:
----------------
bool(true)
PHP Warning: count(): Node no longer exists in /home/goetas/test.php on
line 7
int(0)
Actual result:
--------------
bool(true)
PHP Warning: count(): Node no longer exists in /home/goetas/test.php on
line 7
int(0)
--
Edit bug report at https://bugs.php.net/bug.php?id=75168&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=75168&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=75168&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=75168&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=75168&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=75168&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=75168&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=75168&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=75168&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=75168&r=support
Expected behavior: https://bugs.php.net/fix.php?id=75168&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=75168&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=75168&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=75168&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=75168&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=75168&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=75168&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=75168&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=75168&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=75168&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=75168&r=mysqlcfg