[php-src] master: Merge branch 'PHP-8.6'

From: Date: Fri, 25 Sep 2026 10:51:58 +0000
Subject: [php-src] master: Merge branch 'PHP-8.6'
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-141536@lists.php.net to get a copy of this message
Author: David Carlier (devnexen) Date: 2026-09-25T11:51:20+01:00 Commit: https://github.com/php/php-src/commit/03b57bdc0aa7cd6f88faa60152f69c17f71f5276 Raw diff: https://github.com/php/php-src/commit/03b57bdc0aa7cd6f88faa60152f69c17f71f5276.diff Merge branch 'PHP-8.6' * PHP-8.6: Fix GH-23897: php:function() assertion after failed registerPHPFunctions() Changed paths: A ext/dom/tests/gh23897.phpt A ext/xsl/tests/gh23897.phpt M ext/dom/xpath_callbacks.c Diff: diff --git a/ext/dom/tests/gh23897.phpt b/ext/dom/tests/gh23897.phpt new file mode 100644 index 000000000000..79c465ec1947 --- /dev/null +++ b/ext/dom/tests/gh23897.phpt @@ -0,0 +1,25 @@ +--TEST-- +GH-23897 (Assertion failure in php_dom_xpath_callback_dispatch() after failed registerPhpFunctions()) +--EXTENSIONS-- +dom +--FILE-- +<?php +$dom = new DOMDocument(); +$dom->loadXML('<root/>'); + +$xpath = new DOMXPath($dom); +$xpath->registerNamespace('php', 'http://php.net/xpath'); +try { + $xpath->registerPhpFunctions('testPhpFunction'); +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; +} +try { + var_dump($xpath->evaluate('php:function("testPhpFunction")')); +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; +} +?> +--EXPECT-- +TypeError: DOMXPath::registerPhpFunctions(): Argument #1 ($restrict) must be a callable, function "testPhpFunction" not found or invalid function name +Error: No callbacks were registered diff --git a/ext/dom/xpath_callbacks.c b/ext/dom/xpath_callbacks.c index cb817b41dd3f..e4ad6c59b3d1 100644 --- a/ext/dom/xpath_callbacks.c +++ b/ext/dom/xpath_callbacks.c @@ -412,7 +412,7 @@ static zend_result php_dom_xpath_callback_dispatch(php_dom_xpath_callbacks *xpat { zval callback_retval; - if (UNEXPECTED(ns == NULL)) { + if (UNEXPECTED(ns == NULL || ns->mode == PHP_DOM_REG_FUNC_MODE_NONE)) { zend_throw_error(NULL, "No callbacks were registered"); return FAILURE; } diff --git a/ext/xsl/tests/gh23897.phpt b/ext/xsl/tests/gh23897.phpt new file mode 100644 index 000000000000..cde0113153fc --- /dev/null +++ b/ext/xsl/tests/gh23897.phpt @@ -0,0 +1,36 @@ +--TEST-- +GH-23897 (Assertion failure in php_dom_xpath_callback_dispatch() after failed registerPHPFunctions()) +--EXTENSIONS-- +xsl +--CREDITS-- +YuanchengJiang +--FILE-- +<?php +$dom = new DOMDocument(); +$dom->loadXML('<root><level1/></root>'); + +$xsl = new DOMDocument(); +$xsl->loadXML(<<<XML +<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:php="http://php.net/xsl"> +<xsl:template match="root"> +<xsl:value-of select="php:function('testPhpFunction', .)" /> +</xsl:template> +</xsl:stylesheet> +XML); + +$xslt = new XSLTProcessor(); +try { + $xslt->registerPHPFunctions('testPhpFunction'); +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; +} +$xslt->importStylesheet($xsl); +try { + var_dump($xslt->transformToXml($dom)); +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; +} +?> +--EXPECT-- +TypeError: XSLTProcessor::registerPHPFunctions(): Argument #1 ($functions) must be a callable, function "testPhpFunction" not found or invalid function name +Error: No callbacks were registered

« previous php.cvs (#141536) next »