Skip to content

Commit 15e5cf8

Browse files
committed
Fix return value of xml_parse(_into_struct) for recursive parsing
As of PHP 8.0.0, these functions are supposed to return int, so we cannot return `false`. Since calling the parser recursively is a programmer error, we throw an `Error` in this case. Cf. <#7363>.
1 parent 2c6177a commit 15e5cf8

File tree

2 files changed

+5
-9
lines changed

2 files changed

+5
-9
lines changed

ext/xml/tests/bug73135.phpt

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,6 @@ HERE;
2121
xml_parse($parser, $xml);
2222
?>
2323
--EXPECTF--
24-
Warning: xml_parse(): Parser must not be called recursively in %s%ebug73135.php on line %d
25-
26-
Warning: xml_parse(): Parser must not be called recursively in %s%ebug73135.php on line %d
27-
28-
Warning: xml_parse(): Unable to call handler ahihi() in %s%ebug73135.php on line %d
29-
30-
Warning: xml_parse(): Unable to call handler ahihi() in %s%ebug73135.php on line %d
24+
Fatal error: Uncaught Error: Parser must not be called recursively in %s:%d
25+
Stack trace:
26+
%a

ext/xml/xml.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1258,8 +1258,8 @@ PHP_FUNCTION(xml_parse)
12581258

12591259
parser = Z_XMLPARSER_P(pind);
12601260
if (parser->isparsing) {
1261-
php_error_docref(NULL, E_WARNING, "Parser must not be called recursively");
1262-
RETURN_FALSE;
1261+
zend_throw_error(NULL, "Parser must not be called recursively");
1262+
RETURN_THROWS();
12631263
}
12641264
parser->isparsing = 1;
12651265
ret = XML_Parse(parser->parser, (XML_Char*)data, data_len, isFinal);

0 commit comments

Comments
 (0)