Category
bug · php-src-strict · DOM ID map · pillar 4
Problem
Calling setIdAttribute('id', true) on a detached element, then replaceChild() into the document, must not register that id in the document ID map on Zend/libxml (getElementById stays null). VM returns the replacement element. Probed 2026-07-27 vs Zend 8.2.32.
| Repro |
Zend 8.2.32 |
VM (2026-07-27) |
detached setIdAttribute then replaceChild; getElementById('x') |
null |
b (replacement) |
Control: setIdAttribute on attached node with a new id after replace |
finds node |
finds node (OK) |
Control: removeChild of id'd node |
null |
null (OK) |
php-src reference
PHP implementation target
ext/dom/ ID-map helpers — only register IDs for nodes that are in the document tree; sync on insert/replace/remove like php-src
- PHP-in-PHP; no new
runtime/ C
Repro
./script/docker-exec.sh -- bash -lc '
php test/repro/maintainer_gap_dom_setidattribute_detached_replace.php
php bin/vm.php test/repro/maintainer_gap_dom_setidattribute_detached_replace.php
'
Done when
Category
bug· php-src-strict · DOM ID map · pillar 4Problem
Calling
setIdAttribute('id', true)on a detached element, thenreplaceChild()into the document, must not register that id in the document ID map on Zend/libxml (getElementById staysnull). VM returns the replacement element. Probed 2026-07-27 vs Zend 8.2.32.setIdAttributethenreplaceChild;getElementById('x')nullb(replacement)setIdAttributeon attached node with a new id after replaceremoveChildof id'd nodenullnull(OK)php-src reference
ext/dom/node.c—setIdAttribute/ insert /replaceChildID-map updatesext/dom/document.c—getElementById/ element ID hashtablePHP implementation target
ext/dom/ID-map helpers — only register IDs for nodes that are in the document tree; sync on insert/replace/remove like php-srcruntime/CRepro
Done when
setIdAttribute+replaceChild→getElementByIdisnullon VM (+ JIT/AOT when in scope)setIdAttributeafter insert with a fresh id still resolves.phpt+ keep/updatetest/repro/maintainer_gap_dom_setidattribute_detached_replace.php