diff --git a/NEWS b/NEWS index d46c2514dde..6f54180df20 100644 --- a/NEWS +++ b/NEWS @@ -31,6 +31,8 @@ PHP NEWS DOMElement->getAttributeNames()). (nielsdos) . Fixed bug GH-16151 (Assertion failure in ext/dom/parentnode/tree.c). (nielsdos) + . Fixed bug GH-16190 (Using reflection to call Dom\Node::__construct + causes assertion failure). (nielsdos) - FPM: . Fixed bug GHSA-865w-9rf3-2wh5 (Logs from childrens may be altered). diff --git a/ext/dom/node.c b/ext/dom/node.c index 803237d96fb..5d4f0144c67 100644 --- a/ext/dom/node.c +++ b/ext/dom/node.c @@ -2548,7 +2548,7 @@ PHP_METHOD(Dom_Node, compareDocumentPosition) PHP_METHOD(Dom_Node, __construct) { - ZEND_UNREACHABLE(); + zend_throw_error(NULL, "Cannot directly construct %s, use document methods instead", ZSTR_VAL(Z_OBJCE_P(ZEND_THIS)->name)); } PHP_METHOD(DOMNode, __sleep) diff --git a/ext/dom/tests/gh16190.phpt b/ext/dom/tests/gh16190.phpt new file mode 100644 index 00000000000..d3d83b5eb49 --- /dev/null +++ b/ext/dom/tests/gh16190.phpt @@ -0,0 +1,18 @@ +--TEST-- +GH-16190 (Using reflection to call Dom\Node::__construct causes assertion failure) +--EXTENSIONS-- +dom +--FILE-- +invoke($doc); +} catch (Error $e) { + echo $e->getMessage(), "\n"; +} + +?> +--EXPECT-- +Cannot directly construct Dom\XMLDocument, use document methods instead