Skip to content

Commit 86580c6

Browse files
committed
Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1: Fix GH-11791: Wrong default value of DOMDocument::xmlStandalone
2 parents e76b62b + bf4e7bd commit 86580c6

File tree

4 files changed

+125
-48
lines changed

4 files changed

+125
-48
lines changed

NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ PHP NEWS
1212
(nielsdos)
1313
. Fix DOMCharacterData::replaceWith() with itself. (nielsdos)
1414
. Fix empty argument cases for DOMParentNode methods. (nielsdos)
15+
. Fixed bug GH-11791 (Wrong default value of DOMDocument::xmlStandalone).
16+
(nielsdos)
1517

1618
- FFI:
1719
. Fix leaking definitions when using FFI::cdef()->new(...). (ilutov)

ext/dom/document.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ int dom_document_standalone_read(dom_object *obj, zval *retval)
187187
return FAILURE;
188188
}
189189

190-
ZVAL_BOOL(retval, docp->standalone);
190+
ZVAL_BOOL(retval, docp->standalone > 0);
191191
return SUCCESS;
192192
}
193193

ext/dom/tests/domobject_debug_handler.phpt

Lines changed: 83 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -12,54 +12,90 @@ XML;
1212
$d = new domdocument;
1313
$d->dynamicProperty = new stdclass;
1414
$d->loadXML($xml);
15-
print_r($d);
15+
var_dump($d);
1616
?>
1717
--EXPECTF--
1818
Deprecated: Creation of dynamic property DOMDocument::$dynamicProperty is deprecated in %s on line %d
19-
DOMDocument Object
20-
(
21-
[config] =>
22-
[dynamicProperty] => stdClass Object
23-
(
24-
)
25-
26-
[doctype] =>
27-
[implementation] => (object value omitted)
28-
[documentElement] => (object value omitted)
29-
[actualEncoding] =>
30-
[encoding] =>
31-
[xmlEncoding] =>
32-
[standalone] => 1
33-
[xmlStandalone] => 1
34-
[version] => 1.0
35-
[xmlVersion] => 1.0
36-
[strictErrorChecking] => 1
37-
[documentURI] => %s
38-
[formatOutput] =>
39-
[validateOnParse] =>
40-
[resolveExternals] =>
41-
[preserveWhiteSpace] => 1
42-
[recover] =>
43-
[substituteEntities] =>
44-
[firstElementChild] => (object value omitted)
45-
[lastElementChild] => (object value omitted)
46-
[childElementCount] => 1
47-
[nodeName] => #document
48-
[nodeValue] =>
49-
[nodeType] => 9
50-
[parentNode] =>
51-
[childNodes] => (object value omitted)
52-
[firstChild] => (object value omitted)
53-
[lastChild] => (object value omitted)
54-
[previousSibling] =>
55-
[nextSibling] =>
56-
[attributes] =>
57-
[ownerDocument] =>
58-
[namespaceURI] =>
59-
[prefix] =>
60-
[localName] =>
61-
[baseURI] => %s
62-
[textContent] =>
19+
object(DOMDocument)#1 (39) {
20+
["config"]=>
21+
NULL
22+
["dynamicProperty"]=>
23+
object(stdClass)#2 (0) {
24+
}
25+
["doctype"]=>
26+
NULL
27+
["implementation"]=>
28+
string(22) "(object value omitted)"
29+
["documentElement"]=>
30+
string(22) "(object value omitted)"
31+
["actualEncoding"]=>
32+
NULL
33+
["encoding"]=>
34+
NULL
35+
["xmlEncoding"]=>
36+
NULL
37+
["standalone"]=>
38+
bool(false)
39+
["xmlStandalone"]=>
40+
bool(false)
41+
["version"]=>
42+
string(3) "1.0"
43+
["xmlVersion"]=>
44+
string(3) "1.0"
45+
["strictErrorChecking"]=>
46+
bool(true)
47+
["documentURI"]=>
48+
string(46) "/run/media/niels/MoreData/php-src-FOR-MERGING/"
49+
["formatOutput"]=>
50+
bool(false)
51+
["validateOnParse"]=>
52+
bool(false)
53+
["resolveExternals"]=>
54+
bool(false)
55+
["preserveWhiteSpace"]=>
56+
bool(true)
57+
["recover"]=>
58+
bool(false)
59+
["substituteEntities"]=>
60+
bool(false)
61+
["firstElementChild"]=>
62+
string(22) "(object value omitted)"
63+
["lastElementChild"]=>
64+
string(22) "(object value omitted)"
65+
["childElementCount"]=>
66+
int(1)
67+
["nodeName"]=>
68+
string(9) "#document"
69+
["nodeValue"]=>
70+
NULL
71+
["nodeType"]=>
72+
int(9)
73+
["parentNode"]=>
74+
NULL
75+
["childNodes"]=>
76+
string(22) "(object value omitted)"
77+
["firstChild"]=>
78+
string(22) "(object value omitted)"
79+
["lastChild"]=>
80+
string(22) "(object value omitted)"
81+
["previousSibling"]=>
82+
NULL
83+
["nextSibling"]=>
84+
NULL
85+
["attributes"]=>
86+
NULL
87+
["ownerDocument"]=>
88+
NULL
89+
["namespaceURI"]=>
90+
NULL
91+
["prefix"]=>
92+
string(0) ""
93+
["localName"]=>
94+
NULL
95+
["baseURI"]=>
96+
string(46) "/run/media/niels/MoreData/php-src-FOR-MERGING/"
97+
["textContent"]=>
98+
string(12) "
6399
foobar
64-
65-
)
100+
"
101+
}

ext/dom/tests/gh11791.phpt

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
--TEST--
2+
GH-11791 (Wrong default value of DOMDocument.xmlStandalone)
3+
--EXTENSIONS--
4+
dom
5+
--FILE--
6+
<?php
7+
$doc = new DOMDocument();
8+
$doc->loadXML('<root/>');
9+
var_dump($doc->xmlStandalone);
10+
$doc->xmlStandalone = true;
11+
var_dump($doc->xmlStandalone);
12+
13+
$doc = new DOMDocument();
14+
$doc->loadXML('<?xml version="1.0"?><root/>');
15+
var_dump($doc->xmlStandalone);
16+
$doc->xmlStandalone = true;
17+
var_dump($doc->xmlStandalone);
18+
19+
$doc = new DOMDocument();
20+
$doc->loadXML('<?xml version="1.0" standalone="no"?><root/>');
21+
var_dump($doc->xmlStandalone);
22+
$doc->xmlStandalone = true;
23+
var_dump($doc->xmlStandalone);
24+
25+
$doc = new DOMDocument();
26+
$doc->loadXML('<?xml version="1.0" standalone="yes"?><root/>');
27+
var_dump($doc->xmlStandalone);
28+
$doc->xmlStandalone = false;
29+
var_dump($doc->xmlStandalone);
30+
?>
31+
--EXPECT--
32+
bool(false)
33+
bool(true)
34+
bool(false)
35+
bool(true)
36+
bool(false)
37+
bool(true)
38+
bool(true)
39+
bool(false)

0 commit comments

Comments
 (0)