1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 00:02:20 +01:00

Avoid warning on exception in xsl ext

This commit is contained in:
Nikita Popov
2020-06-25 15:06:53 +02:00
parent 5c37715dfd
commit 049467d365
3 changed files with 46 additions and 3 deletions

View File

@@ -9,8 +9,8 @@ if (getenv('SKIP_ASAN')) die('xfail bailing out across foreign C code');
<?php
spl_autoload_register(function ($className) {
var_dump($className);
exit();
var_dump($className);
exit();
});
$xsl = new DomDocument();

View File

@@ -0,0 +1,41 @@
--TEST--
Fork of bug33853.phpt with exit replaced by throw
--SKIPIF--
<?php
if (!extension_loaded('xsl')) die('skip xsl not loaded');
?>
--FILE--
<?php
spl_autoload_register(function ($className) {
var_dump($className);
throw new Exception("Autoload exception");
});
$xsl = new DomDocument();
$xsl->loadXML('<?xml version="1.0" encoding="iso-8859-1" ?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:php="http://php.net/xsl">
<xsl:template match="/">
<xsl:value-of select="php:function(\'TeSt::dateLang\')" />
</xsl:template>
</xsl:stylesheet>');
$inputdom = new DomDocument();
$inputdom->loadXML('<?xml version="1.0" encoding="iso-8859-1" ?>
<today></today>');
$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===

View File

@@ -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));