1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 08:12:21 +01:00
Files
archived-php-src/ext/simplexml/tests/bug62639.phpt
Niels Dossche b842ea4fa8 Apply SimpleXML iterator fixes only on master
Many methods in SimpleXML reset the iterator when called. This has the
consequence that mixing these operations with loops can cause infinite
loops, or the loss of iteration data.
Some people may however rely on the resetting behaviour. To prevent
unintended breaks in stable branches, let's only apply the fix to master.

This reverts GH-12193, GH-12229, GG-12247 for stable branches while
keeping them on master, adding a note in UPGRADING as well.
2023-09-30 17:48:05 +02:00

62 lines
870 B
PHP

--TEST--
Bug #62639 (XML structure broken)
--EXTENSIONS--
simplexml
--FILE--
<?php
class A extends SimpleXMLElement
{
}
$xml1 = <<<XML
<?xml version="1.0"?>
<a>
<b>
<c>
<value attr="Some Attr">Some Value</value>
</c>
</b>
</a>
XML;
$a1 = new A($xml1);
foreach ($a1->b->c->children() as $key => $value) {
var_dump($value);
}
$xml2 = <<<XML
<?xml version="1.0"?>
<a>
<b>
<c><value attr="Some Attr">Some Value</value></c>
</b>
</a>
XML;
$a2 = new A($xml2);
foreach ($a2->b->c->children() as $key => $value) {
var_dump($value);
}?>
--EXPECT--
object(A)#4 (2) {
["@attributes"]=>
array(1) {
["attr"]=>
string(9) "Some Attr"
}
[0]=>
string(10) "Some Value"
}
object(A)#6 (2) {
["@attributes"]=>
array(1) {
["attr"]=>
string(9) "Some Attr"
}
[0]=>
string(10) "Some Value"
}