|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2017-08-31 14:31 UTC] cmb@php.net
[2017-08-31 17:42 UTC] marijn at suninet dot org
-Summary: Undocumented break from 5.6 using XML namespaces and
assigning value by key.
+Summary: Breaking change in 7.0.12 using XML namespaces and
assigning value by key.
[2017-08-31 17:42 UTC] marijn at suninet dot org
[2017-09-01 16:34 UTC] cmb@php.net
-Status: Open
+Status: Verified
-Type: Documentation Problem
+Type: Bug
[2017-09-01 16:34 UTC] cmb@php.net
[2017-09-01 16:59 UTC] nikic@php.net
[2017-09-11 04:55 UTC] marijn at suninet dot org
-Summary: Breaking change in 7.0.12 using XML namespaces and
assigning value by key.
+Summary: marijn@suninet.org
[2017-09-11 04:55 UTC] marijn at suninet dot org
[2017-09-13 15:24 UTC] cmb@php.net
-Summary: marijn@suninet.org
+Summary: Insufficient documentation regarding namespaces
-Type: Bug
+Type: Documentation Problem
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Oct 30 03:00:01 2025 UTC |
Description: ------------ Hi, I've been looking around but I haven't been able to find anything. If you assign a value to an XML element by using an array key when XML namespaces are used the behaviour is changed between PHP 5.6 and PHP 7.0. This is something we couldn't anywhere in the documentation around backwards incompatibility. It could have something to do with "Changes to the handling of indirect variables, properties, and methods" but from my understanding reading that section that is about when you use dynamic variable assignments which is not the case here. In the expected/actual result you can see the difference. The expected result is what you get when running the sample code in PHP 5.6 and the actual result is what you get when running the sample code in PHP 7.0. My guess is that this is not a bug but rather an undocumented backward incompatible change between the PHP versions. Regards, Marijn. Test script: --------------- <?php $xml = new SimpleXMLElement('<xml xmlns="http://xml" xmlns:foo="http://foo" xmlns:bar="http://bar" />'); $foo = $xml->addChild('foo', null, 'http://foo'); $tag = $foo->addChild('bar', null, 'http://bar'); $foo->bar[0] = 'Hello World!'; $dom = dom_import_simplexml($xml)->ownerDocument; $dom->formatOutput = true; echo $dom->saveXML(); Expected result: ---------------- $ php-5.6 test.php <?xml version="1.0"?> <xml xmlns="http://xml" xmlns:foo="http://foo" xmlns:bar="http://bar"> <foo:foo> <bar:bar>Hello World!</bar:bar> </foo:foo> </xml> Actual result: -------------- $ php-7.0 test.php <?xml version="1.0"?> <xml xmlns="http://xml" xmlns:foo="http://foo" xmlns:bar="http://bar"> <foo:foo> <bar:bar/> <foo:bar>Hello World!</foo:bar> </foo:foo> </xml>