From 15e5cf856a82e8e6f0f42dbd97abd5fba75998ec Mon Sep 17 00:00:00 2001 From: "Christoph M. Becker" Date: Fri, 13 Aug 2021 18:57:08 +0200 Subject: [PATCH] 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. . --- ext/xml/tests/bug73135.phpt | 10 +++------- ext/xml/xml.c | 4 ++-- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/ext/xml/tests/bug73135.phpt b/ext/xml/tests/bug73135.phpt index ef1ca6c7598..e3baee9a570 100644 --- a/ext/xml/tests/bug73135.phpt +++ b/ext/xml/tests/bug73135.phpt @@ -21,10 +21,6 @@ HERE; xml_parse($parser, $xml); ?> --EXPECTF-- -Warning: xml_parse(): Parser must not be called recursively in %s%ebug73135.php on line %d - -Warning: xml_parse(): Parser must not be called recursively in %s%ebug73135.php on line %d - -Warning: xml_parse(): Unable to call handler ahihi() in %s%ebug73135.php on line %d - -Warning: xml_parse(): Unable to call handler ahihi() in %s%ebug73135.php on line %d +Fatal error: Uncaught Error: Parser must not be called recursively in %s:%d +Stack trace: +%a diff --git a/ext/xml/xml.c b/ext/xml/xml.c index d10075603ca..985b763e423 100644 --- a/ext/xml/xml.c +++ b/ext/xml/xml.c @@ -1258,8 +1258,8 @@ PHP_FUNCTION(xml_parse) parser = Z_XMLPARSER_P(pind); if (parser->isparsing) { - php_error_docref(NULL, E_WARNING, "Parser must not be called recursively"); - RETURN_FALSE; + zend_throw_error(NULL, "Parser must not be called recursively"); + RETURN_THROWS(); } parser->isparsing = 1; ret = XML_Parse(parser->parser, (XML_Char*)data, data_len, isFinal);