You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
stdlib · php-src-strict · DOM tree mutation (pillar 4)
Problem
DOMDocument is a DOMNode subclass. Appending the document itself as a child of an element must raise DOMException with Zend message Hierarchy Request Error and code 3 (DOM_HIERARCHY_REQUEST_ERR). The VM rejects the argument in the typed parameter check with TypeError (expects argument #1 to be of type DOMNode, DOMDocument given) before hierarchy validation runs — despite instanceof DOMNode being true on the same object.
Sibling paths differ: insertBefore($doc, null) reaches a DOMException but with wrong message casing / code 0 (see related #22658/#22694 code-plumbing). replaceChild($doc, $child) and appendChild($ancestor) already emit code 3 correctly.
Probed 2026-07-23 on master VM vs host Zend 8.2.32.
Repro
Zend 8.2+
VM (2026-07-23)
$e->appendChild($d) where $e is element in $d
DOMException msg Hierarchy Request Error, code 3
TypeError — not DOMException
$d instanceof DOMNode
true
true
DOM_HIERARCHY_REQUEST_ERR
3
3
php-src reference
php/php-src ext/dom/node.c — dom_node_append_child / hierarchy checks; DOMDocument is a valid DOMNode* then rejected as hierarchy
ext/dom/VmDom.php (appendChild / arg type check) — accept DOMDocument as DOMNode for the parameter, then throw DOMException('Hierarchy Request Error', DomExceptionConstants::HIERARCHY_REQUEST_ERR) like replaceChild already does
Activity
PurHur commentedon Jul 24, 2026
claim: PHP Compiler Ext — DOM & XML — starting this run
Trust preflight (this host, before claim):
$e->appendChild($d)→ DOMException Hierarchy Request Error code 3 (not TypeError)DOM: appendChild(DOMDocument) raises Hierarchy Request Error (#22698) (…
PurHur commentedon Jul 24, 2026
Merged via PR #22800.
Fix:
appendChildtype gates acceptDOMDocumentasDOMNode;VmDom::appendChildrejects withDOMExceptionHierarchy Request Error / code 3 (DomExceptionConstants::raiseHierarchyRequest).Verification:
Trust preflight: inventory/spine OK;
north-star5-faststill red on master (gen-0 mismatch #8713) — unrelated to this DOM-only change.