[php-src] Issue #11500: Namespace reuse in createElementNS() generates wrong output
| From: | ausi | Date: | Wed, 21 Jun 2023 16:02:09 +0000 |
| Subject: | [php-src] Issue #11500: Namespace reuse in createElementNS() generates wrong output | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-244771@lists.php.net to get a copy of this message | ||
Issue: https://github.com/php/php-src/issues/11500
Author: ausi
### Description
The following code:
```php
<?php
$dom = new \DOMDocument();
$root = $dom->createElementNS('http://example.com', 'root');
$dom->appendChild($root);
$a1 = $dom->createElementNS('http://example.com', 'a');
$a1->appendChild($dom->createElementNS('http://example.com', 'b'));
$root->appendChild($a1);
$a2 = $dom->createElementNS('http://example.com', 'a');
$a2->appendChild($dom->createElementNS('http://example.com', 'b'));
$root->appendChild($a2);
echo $dom->saveXML();
```
Resulted in this output:
```xml
<?xml version="1.0"?>
<root xmlns="http://example.com"><a><b/></a><a><b
xmlns="http://example.com"/></a></root>
```
But I expected this output instead:
```xml
<?xml version="1.0"?>
<root xmlns="http://example.com"><a><b/></a><a><b/></a></root>
```
Only the nightly build from the master branch seems to be affected. With the stable releases this
bug does not occur, see https://3v4l.org/hAXOS
Related: https://github.com/php/php-src/pull/11428#issuecomment-1600879625
### PHP Version
8.3.0-dev fe6263e2437b312f9a8b685013cf194f31238a38
### Operating System
_No response_