From: robin2008 at altruists dot org
Operating system: Ubuntu
PHP version: 5.2.8
PHP Bug Type: DOM XML related
Bug description: insertBefore can lose the namespace of an XML element
Description:
------------
If the namespace of the insertBefore()'d element equals that of its
parent, it loses the xmlns attribute, so becomes unnamespaced:( !
Reproduce code:
---------------
<?php
$main= DOMDocument::loadXML('<?xml version="1.0"?><f2f:no-xmlns
xmlns:f2f="http://friend2friend.net"/>');
$new= $main->createElement('new');
$new->setAttribute('xmlns', 'http://friend2friend.net');
echo 'Main document= '.$main->saveXML().chr(13);
echo 'New element= '.$main->saveXML($new).chr(13).chr(13);
$main->firstChild->insertBefore($new, $main->firstChild->firstChild);
echo 'insertBefore() changes <new> into an unnamespaced node iff its NS
matched the parent node :-( '.$main->saveXML();
?>
Expected result:
----------------
Shouldn't lose the namespace. i.e.
<f2f:no-xmlns
xmlns:f2f="http://friend2friend.net"><f2f:new/></f2f:no-xmlns>
Actual result:
--------------
Loses the NS:
<f2f:no-xmlns xmlns:f2f="http://friend2friend.net"><new/></f2f:no-xmlns>
--
Edit bug report at http://bugs.php.net/?id=47490&edit=1
--
Try a CVS snapshot (PHP 5.2):
http://bugs.php.net/fix.php?id=47490&r=trysnapshot52
Try a CVS snapshot (PHP 5.3):
http://bugs.php.net/fix.php?id=47490&r=trysnapshot53
Try a CVS snapshot (PHP 6.0):
http://bugs.php.net/fix.php?id=47490&r=trysnapshot60
Fixed in CVS:
http://bugs.php.net/fix.php?id=47490&r=fixedcvs
Fixed in CVS and need be documented:
http://bugs.php.net/fix.php?id=47490&r=needdocs
Fixed in release:
http://bugs.php.net/fix.php?id=47490&r=alreadyfixed
Need backtrace:
http://bugs.php.net/fix.php?id=47490&r=needtrace
Need Reproduce Script:
http://bugs.php.net/fix.php?id=47490&r=needscript
Try newer version:
http://bugs.php.net/fix.php?id=47490&r=oldversion
Not developer issue:
http://bugs.php.net/fix.php?id=47490&r=support
Expected behavior:
http://bugs.php.net/fix.php?id=47490&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=47490&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=47490&r=submittedtwice
register_globals:
http://bugs.php.net/fix.php?id=47490&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=47490&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=47490&r=dst
IIS Stability:
http://bugs.php.net/fix.php?id=47490&r=isapi
Install GNU Sed:
http://bugs.php.net/fix.php?id=47490&r=gnused
Floating point limitations:
http://bugs.php.net/fix.php?id=47490&r=float
No Zend Extensions:
http://bugs.php.net/fix.php?id=47490&r=nozend
MySQL Configuration Error:
http://bugs.php.net/fix.php?id=47490&r=mysqlcfg