Bug #75624 [NEW]: DOMNode::$prefix not NULL when unspecified

From: Date: Mon, 04 Dec 2017 16:53:01 +0000
Subject: Bug #75624 [NEW]: DOMNode::$prefix not NULL when unspecified
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-212912@lists.php.net to get a copy of this message
From: bit2shift at gmail dot com Operating system: Win7 Pro x64 PHP version: 5.6.32 Package: DOM XML related Bug Type: Bug Bug description:DOMNode::$prefix not NULL when unspecified Description: ------------ --- From manual page: http://www.php.net/class.domnode --- The documentation states that $prefix is NULL if it is unspecified, but instead I'm getting an empty string. This causes an annoyance when passing it through to XMLWriter::startElementNs(), as it'll output (an example) <:derp> instead of <derp>. Test script: --------------- <?php $doc = new DOMDocument(); $doc->loadXML('<derp></derp>'); $root = $doc->documentElement; echo "prefix: [$root->prefix]<br>"; echo "name: [$root->localName]<br>"; echo 'is the prefix NULL? ' . (is_null($root->prefix) ? 'yep' : 'nope'); var_dump($root); Expected result: ---------------- prefix: [] name: [derp] is the prefix NULL? yep --omitted--\test.php:9: object(DOMElement)[2] public 'tagName' => string 'derp' (length=4) public 'schemaTypeInfo' => null public 'nodeName' => string 'derp' (length=4) public 'nodeValue' => string '' (length=0) public 'nodeType' => int 1 public 'parentNode' => string '(object value omitted)' (length=22) public 'childNodes' => string '(object value omitted)' (length=22) public 'firstChild' => null public 'lastChild' => null public 'previousSibling' => null public 'attributes' => string '(object value omitted)' (length=22) public 'ownerDocument' => string '(object value omitted)' (length=22) public 'namespaceURI' => null public 'prefix' => null public 'localName' => string 'derp' (length=4) public 'baseURI' => string 'file:/--omitted--/' (length=46) public 'textContent' => string '' (length=0) Actual result: -------------- prefix: [] name: [derp] is the prefix NULL? nope --omitted--\test.php:9: object(DOMElement)[2] public 'tagName' => string 'derp' (length=4) public 'schemaTypeInfo' => null public 'nodeName' => string 'derp' (length=4) public 'nodeValue' => string '' (length=0) public 'nodeType' => int 1 public 'parentNode' => string '(object value omitted)' (length=22) public 'childNodes' => string '(object value omitted)' (length=22) public 'firstChild' => null public 'lastChild' => null public 'previousSibling' => null public 'attributes' => string '(object value omitted)' (length=22) public 'ownerDocument' => string '(object value omitted)' (length=22) public 'namespaceURI' => null public 'prefix' => string '' (length=0) public 'localName' => string 'derp' (length=4) public 'baseURI' => string 'file:/--omitted--/' (length=46) public 'textContent' => string '' (length=0) -- Edit bug report at https://bugs.php.net/bug.php?id=75624&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=75624&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=75624&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=75624&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=75624&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=75624&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=75624&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=75624&r=needscript Try newer version: https://bugs.php.net/fix.php?id=75624&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=75624&r=support Expected behavior: https://bugs.php.net/fix.php?id=75624&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=75624&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=75624&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=75624&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=75624&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=75624&r=dst IIS Stability: https://bugs.php.net/fix.php?id=75624&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=75624&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=75624&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=75624&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=75624&r=mysqlcfg

« previous php.bugs (#212912) next »