From 049467d365bd090a507f4cf26ee6907a59833887 Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Thu, 25 Jun 2020 15:06:53 +0200 Subject: [PATCH] Avoid warning on exception in xsl ext --- ext/xsl/tests/bug33853.phpt | 4 +-- ext/xsl/tests/throw_in_autoload.phpt | 41 ++++++++++++++++++++++++++++ ext/xsl/xsltprocessor.c | 4 ++- 3 files changed, 46 insertions(+), 3 deletions(-) create mode 100644 ext/xsl/tests/throw_in_autoload.phpt diff --git a/ext/xsl/tests/bug33853.phpt b/ext/xsl/tests/bug33853.phpt index a2e835ff6d4..815ea03a257 100644 --- a/ext/xsl/tests/bug33853.phpt +++ b/ext/xsl/tests/bug33853.phpt @@ -9,8 +9,8 @@ if (getenv('SKIP_ASAN')) die('xfail bailing out across foreign C code'); +--FILE-- +loadXML(' + + + + +'); +$inputdom = new DomDocument(); +$inputdom->loadXML(' +'); + +$proc = new XsltProcessor(); +$proc->registerPhpFunctions(); +$xsl = $proc->importStylesheet($xsl); +try { + $newdom = $proc->transformToDoc($inputdom); +} catch (Exception $e) { + echo $e->getMessage(), "\n"; +} +?> +===DONE=== +--EXPECT-- +string(4) "TeSt" +Autoload exception +===DONE=== diff --git a/ext/xsl/xsltprocessor.c b/ext/xsl/xsltprocessor.c index 6693ac40216..968ed2f3d7f 100644 --- a/ext/xsl/xsltprocessor.c +++ b/ext/xsl/xsltprocessor.c @@ -248,7 +248,9 @@ static void xsl_ext_function_php(xmlXPathParserContextPtr ctxt, int nargs, int t fci.no_separation = 0; /*fci.function_handler_cache = &function_ptr;*/ if (!zend_make_callable(&handler, &callable)) { - php_error_docref(NULL, E_WARNING, "Unable to call handler %s()", ZSTR_VAL(callable)); + if (!EG(exception)) { + php_error_docref(NULL, E_WARNING, "Unable to call handler %s()", ZSTR_VAL(callable)); + } valuePush(ctxt, xmlXPathNewString((const xmlChar *) "")); } else if ( intern->registerPhpFunctions == 2 && zend_hash_exists(intern->registered_phpfunctions, callable) == 0) { php_error_docref(NULL, E_WARNING, "Not allowed to call handler '%s()'", ZSTR_VAL(callable));