Skip to content

Commit 049467d

Browse files
committed
Avoid warning on exception in xsl ext
1 parent 5c37715 commit 049467d

File tree

3 files changed

+46
-3
lines changed

3 files changed

+46
-3
lines changed

ext/xsl/tests/bug33853.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ if (getenv('SKIP_ASAN')) die('xfail bailing out across foreign C code');
99
<?php
1010

1111
spl_autoload_register(function ($className) {
12-
var_dump($className);
13-
exit();
12+
var_dump($className);
13+
exit();
1414
});
1515

1616
$xsl = new DomDocument();

ext/xsl/tests/throw_in_autoload.phpt

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
--TEST--
2+
Fork of bug33853.phpt with exit replaced by throw
3+
--SKIPIF--
4+
<?php
5+
if (!extension_loaded('xsl')) die('skip xsl not loaded');
6+
?>
7+
--FILE--
8+
<?php
9+
10+
spl_autoload_register(function ($className) {
11+
var_dump($className);
12+
throw new Exception("Autoload exception");
13+
});
14+
15+
$xsl = new DomDocument();
16+
$xsl->loadXML('<?xml version="1.0" encoding="iso-8859-1" ?>
17+
<xsl:stylesheet version="1.0"
18+
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
19+
xmlns:php="http://php.net/xsl">
20+
<xsl:template match="/">
21+
<xsl:value-of select="php:function(\'TeSt::dateLang\')" />
22+
</xsl:template>
23+
</xsl:stylesheet>');
24+
$inputdom = new DomDocument();
25+
$inputdom->loadXML('<?xml version="1.0" encoding="iso-8859-1" ?>
26+
<today></today>');
27+
28+
$proc = new XsltProcessor();
29+
$proc->registerPhpFunctions();
30+
$xsl = $proc->importStylesheet($xsl);
31+
try {
32+
$newdom = $proc->transformToDoc($inputdom);
33+
} catch (Exception $e) {
34+
echo $e->getMessage(), "\n";
35+
}
36+
?>
37+
===DONE===
38+
--EXPECT--
39+
string(4) "TeSt"
40+
Autoload exception
41+
===DONE===

ext/xsl/xsltprocessor.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,9 @@ static void xsl_ext_function_php(xmlXPathParserContextPtr ctxt, int nargs, int t
248248
fci.no_separation = 0;
249249
/*fci.function_handler_cache = &function_ptr;*/
250250
if (!zend_make_callable(&handler, &callable)) {
251-
php_error_docref(NULL, E_WARNING, "Unable to call handler %s()", ZSTR_VAL(callable));
251+
if (!EG(exception)) {
252+
php_error_docref(NULL, E_WARNING, "Unable to call handler %s()", ZSTR_VAL(callable));
253+
}
252254
valuePush(ctxt, xmlXPathNewString((const xmlChar *) ""));
253255
} else if ( intern->registerPhpFunctions == 2 && zend_hash_exists(intern->registered_phpfunctions, callable) == 0) {
254256
php_error_docref(NULL, E_WARNING, "Not allowed to call handler '%s()'", ZSTR_VAL(callable));

0 commit comments

Comments
 (0)