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
Passing a foreignDOMDocument (another document object) to DOMNode::appendChild(), insertBefore(), or replaceChild() must raise DOMExceptionWrong Document Error with code 4 (WRONG_DOCUMENT_ERR). The VM raises Hierarchy Request Error (code 3) for appendChild/replaceChild, and insertBefore raises lowercase "Hierarchy request error" with code 0.
Same-document $el->appendChild($el->ownerDocument) correctly stays Hierarchy Request Error code 3 (covered by #22698). This is the foreign-document sibling case.
Repro
Zend 8.2.32
VM (2026-08-11)
$el->appendChild($otherDoc)
Wrong Document Error / code=4
Hierarchy Request Error / code=3
$el->insertBefore($otherDoc, $ref)
Wrong Document Error / code=4
Hierarchy request error / code=0
$el->replaceChild($otherDoc, $old)
Wrong Document Error / code=4
Hierarchy Request Error / code=3
$el->appendChild($sameDoc)
Hierarchy Request Error / code=3
Hierarchy Request Error / code=3 (OK)
php-src reference
php/php-src ext/dom/node.c — dom_node_append_child / dom_node_insert_before / dom_node_replace_child: document mismatch → WRONG_DOCUMENT_ERR before hierarchy type rejection for XML_DOCUMENT_NODE.
PHP implementation target
ext/dom/VmDom.php — appendChild / insertBefore / replaceChild: call assertSameDocumentbefore rejecting non-isTreeMutationChild nodes with Hierarchy Request; use DomExceptionConstants::raiseHierarchyRequest() in insertBefore (canonical message + code 3).
Gate snapshot (mandatory pre-work)
bootstrap-inventory --check: OK 7364/7364 (release-readiness)
check-helper-runtime-prelink --strict: 378 fresh, 0 stale
Activity
PurHur commentedon Aug 11, 2026
claim: PHP Compiler Ext — DOM & XML — starting this run
Gate snapshot before claim:
PurHur commentedon Aug 11, 2026
Status
VM + JIT fixed and matching Zend. Thin-AOT LiveSlots path still skips NestedJIT exception checks — filed follow-up #30274.
Verification (2026-08-11)
Zend/VM/JIT identical:
Gate snapshot before claim:
user_release_ready: yes(gen-0 stale → #28998).Stdlib: foreign DOMDocument mutations raise Wrong Document Error (#30271
PurHur commentedon Aug 11, 2026
Merged via #30277
Verified: Zend/VM/JIT match on foreign DOMDocument Wrong Document (code 4) and same-document Hierarchy Request (code 3).
Not covered: thin-AOT LiveSlots — #30274.