Skip to content

Commit 8e02be1

Browse files
committed
Merge branch 'PHP-5.5' into PHP-5.6
* PHP-5.5: Refactored the fix for bug #66084, by cmb@php.net Merge the fix for #69703 to 5.5 per request from Julien
2 parents e7d0ca3 + 5683b6f commit 8e02be1

File tree

7 files changed

+299
-1
lines changed

7 files changed

+299
-1
lines changed

ext/simplexml/simplexml.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1129,7 +1129,7 @@ static HashTable * sxe_get_prop_hash(zval *object, int is_debug TSRMLS_DC) /* {{
11291129
node = NULL;
11301130
} else if (sxe->iter.type != SXE_ITER_CHILD) {
11311131

1132-
if ( !node->children || !node->parent || !node->next || node->children->next || node->children->children || node->parent->children == node->parent->last ) {
1132+
if ( sxe->iter.type == SXE_ITER_NONE || !node->children || !node->parent || node->children->next || node->children->children || node->parent->children == node->parent->last ) {
11331133
node = node->children;
11341134
} else {
11351135
iter_data = sxe->iter.data;

ext/simplexml/tests/bug61335.phpt

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
--TEST--
2+
Bug #61335 - Access to array node returns wrong truth value
3+
--SKIPIF--
4+
<?php
5+
if (!extension_loaded("simplexml")) die("skip SimpleXML not available");
6+
?>
7+
--FILE--
8+
<?php
9+
$rec1 = simplexml_load_string("<foo><bar>aa</bar>\n</foo>");
10+
$rec2 = simplexml_load_string("<foo><bar>aa</bar></foo>");
11+
12+
if ($rec1->bar[0]) echo "NONEMPTY1\n";
13+
if ($rec1->bar[0] . "") echo "NONEMPTY2\n";
14+
if ($rec2->bar[0]) echo "NONEMPTY3\n";
15+
?>
16+
--EXPECT--
17+
NONEMPTY1
18+
NONEMPTY2
19+
NONEMPTY3

ext/simplexml/tests/bug62639.phpt

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
--TEST--
2+
Bug #62639 (XML structure broken)
3+
--SKIPIF--
4+
<?php
5+
if (!extension_loaded("simplexml")) die("skip SimpleXML not available");
6+
?>
7+
--FILE--
8+
<?php
9+
10+
class A extends SimpleXMLElement
11+
{
12+
}
13+
14+
$xml1 = <<<XML
15+
<?xml version="1.0"?>
16+
<a>
17+
<b>
18+
<c>
19+
<value attr="Some Attr">Some Value</value>
20+
</c>
21+
</b>
22+
</a>
23+
XML;
24+
25+
$a1 = new A($xml1);
26+
27+
foreach ($a1->b->c->children() as $key => $value) {
28+
var_dump($value);
29+
}
30+
31+
$xml2 = <<<XML
32+
<?xml version="1.0"?>
33+
<a>
34+
<b>
35+
<c><value attr="Some Attr">Some Value</value></c>
36+
</b>
37+
</a>
38+
XML;
39+
40+
$a2 = new A($xml2);
41+
42+
foreach ($a2->b->c->children() as $key => $value) {
43+
var_dump($value);
44+
}?>
45+
--EXPECT--
46+
object(A)#2 (2) {
47+
["@attributes"]=>
48+
array(1) {
49+
["attr"]=>
50+
string(9) "Some Attr"
51+
}
52+
[0]=>
53+
string(10) "Some Value"
54+
}
55+
object(A)#3 (2) {
56+
["@attributes"]=>
57+
array(1) {
58+
["attr"]=>
59+
string(9) "Some Attr"
60+
}
61+
[0]=>
62+
string(10) "Some Value"
63+
}

ext/simplexml/tests/bug67116.phpt

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
--TEST--
2+
Bug #67116 (Inconsistent parsing of Nodes w/o linefeed)
3+
--SKIPIF--
4+
<?php
5+
if (!extension_loaded("simplexml")) die("skip SimpleXML not available");
6+
?>
7+
--FILE--
8+
<?php
9+
10+
$xml = <<<XML
11+
<?xml version="1.0" encoding="UTF-8"?>
12+
<aa>
13+
<bs>
14+
<b>b</b>
15+
</bs>
16+
<cs><c>b</c></cs>
17+
<ds><d id="d"></d></ds>
18+
<es>
19+
<e id="e"></e>
20+
</es>
21+
<fs><f id="f"></f><f id="f"></f></fs>
22+
</aa>
23+
XML;
24+
$sxe = simplexml_load_string($xml);
25+
print_r($sxe);
26+
27+
?>
28+
--EXPECT--
29+
SimpleXMLElement Object
30+
(
31+
[bs] => SimpleXMLElement Object
32+
(
33+
[b] => b
34+
)
35+
36+
[cs] => SimpleXMLElement Object
37+
(
38+
[c] => b
39+
)
40+
41+
[ds] => SimpleXMLElement Object
42+
(
43+
[d] => SimpleXMLElement Object
44+
(
45+
[@attributes] => Array
46+
(
47+
[id] => d
48+
)
49+
50+
)
51+
52+
)
53+
54+
[es] => SimpleXMLElement Object
55+
(
56+
[e] => SimpleXMLElement Object
57+
(
58+
[@attributes] => Array
59+
(
60+
[id] => e
61+
)
62+
63+
)
64+
65+
)
66+
67+
[fs] => SimpleXMLElement Object
68+
(
69+
[f] => Array
70+
(
71+
[0] => SimpleXMLElement Object
72+
(
73+
[@attributes] => Array
74+
(
75+
[id] => f
76+
)
77+
78+
)
79+
80+
[1] => SimpleXMLElement Object
81+
(
82+
[@attributes] => Array
83+
(
84+
[id] => f
85+
)
86+
87+
)
88+
89+
)
90+
91+
)
92+
93+
)

ext/simplexml/tests/bug67572.phpt

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
--TEST--
2+
Bug #67572 - SimpleXMLElement not parsing \n correctly
3+
--SKIPIF--
4+
<?php
5+
if (!extension_loaded("simplexml")) die("skip SimpleXML not available");
6+
?>
7+
--FILE--
8+
<?php
9+
$foo = 'bar';
10+
print "regular string ... ";
11+
var_dump(empty($foo));
12+
13+
$xml = simplexml_load_string("<xml><something>somevalue</something></xml>");
14+
$xml2 = simplexml_load_string("<xml>\n<something>somevalue</something>\n</xml>");
15+
16+
foreach($xml as $key => $value) {
17+
print "$key = $value ... ";
18+
var_dump(empty($value));
19+
var_dump($value == false);
20+
}
21+
22+
foreach($xml2 as $key => $value) {
23+
print "$key = $value ... ";
24+
var_dump(empty($value));
25+
var_dump($value == false);
26+
}
27+
?>
28+
--EXPECT--
29+
regular string ... bool(false)
30+
something = somevalue ... bool(false)
31+
bool(false)
32+
something = somevalue ... bool(false)
33+
bool(false)

ext/simplexml/tests/bug69169.phpt

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
--TEST--
2+
Bug #69169 (simplexml_load_string parse wrongly when xml given in one row)
3+
--SKIPIF--
4+
<?php
5+
if (!extension_loaded("simplexml")) die("skip SimpleXML not available");
6+
?>
7+
--FILE--
8+
<?php
9+
$a = '<?xml version="1.0" encoding="UTF-8"?>
10+
<root a="b">
11+
<row b="y">
12+
<item s="t" />
13+
</row>
14+
<row p="c">
15+
<item y="n" />
16+
</row>
17+
</root>';
18+
$b = str_replace(array("\n", "\r", "\t"), "", $a);
19+
$simple_xml = simplexml_load_string($b);
20+
print_r($simple_xml);
21+
?>
22+
--EXPECT--
23+
SimpleXMLElement Object
24+
(
25+
[@attributes] => Array
26+
(
27+
[a] => b
28+
)
29+
30+
[row] => Array
31+
(
32+
[0] => SimpleXMLElement Object
33+
(
34+
[@attributes] => Array
35+
(
36+
[b] => y
37+
)
38+
39+
[item] => SimpleXMLElement Object
40+
(
41+
[@attributes] => Array
42+
(
43+
[s] => t
44+
)
45+
46+
)
47+
48+
)
49+
50+
[1] => SimpleXMLElement Object
51+
(
52+
[@attributes] => Array
53+
(
54+
[p] => c
55+
)
56+
57+
[item] => SimpleXMLElement Object
58+
(
59+
[@attributes] => Array
60+
(
61+
[y] => n
62+
)
63+
64+
)
65+
66+
)
67+
68+
)
69+
70+
)

ext/simplexml/tests/bug69491.phpt

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
--TEST--
2+
Bug #69491 (simplexml doesn't correctly parse empty nodes on same line as another node)
3+
--SKIPIF--
4+
<?php
5+
if (!extension_loaded("simplexml")) die("skip SimpleXML not available");
6+
?>
7+
--FILE--
8+
<?php
9+
var_dump(simplexml_load_string('<a>
10+
<b><c/></b>
11+
</a>'));?>
12+
--EXPECT--
13+
object(SimpleXMLElement)#1 (1) {
14+
["b"]=>
15+
object(SimpleXMLElement)#2 (1) {
16+
["c"]=>
17+
object(SimpleXMLElement)#3 (0) {
18+
}
19+
}
20+
}

0 commit comments

Comments
 (0)