Skip to content

Regression: DOMNamedNodeMap::getNamedItem uses qName — Zend matches local name for namespaced attrs (ext/dom/nodemap.c) #24332

Description

@PurHur

Category

bug · php-src-strict · DOM NamedNodeMap

Problem

For a namespaced attribute (xmlns:x="urn:x" x:a="1"), Zend DOMNamedNodeMap::getNamedItem("a") returns the Attr (lookup by local name). getNamedItem("x:a") returns null. VM inverts this: local name misses, qualified name hits.

Repro Zend 8.2 (2026-07-28) VM (2026-07-28)
getNamedItem("a") on x:a="1" Attr nodeValue 1 null
getNamedItem("x:a") null Attr nodeValue 1
getNamedItemNS("urn:x","a") 1 (both) 1 (both)

php-src reference

PHP implementation target

  • ext/dom/ NamedNodeMap getNamedItem — match php-src local-name lookup for namespaced Attr nodes; do not key solely on node->name / qName string

Repro

./script/docker-exec.sh -- bash -lc 'cat > /tmp/getnameditem_ns.php <<'"'"'PHP'"'"'
<?php
$doc = new DOMDocument();
$doc->loadXML("<root xmlns:x=\"urn:x\" x:a=\"1\" b=\"2\"/>");
$m = $doc->documentElement->attributes;
echo "local=", var_export($m->getNamedItem("a")?->nodeValue, true), "\n";
echo "qname=", var_export($m->getNamedItem("x:a")?->nodeValue, true), "\n";
PHP
php /tmp/getnameditem_ns.php; php bin/vm.php /tmp/getnameditem_ns.php'

Done when

  • getNamedItem("a") returns the namespaced Attr; getNamedItem("x:a") returns null (VM + JIT/AOT in scope)
  • Non-namespaced getNamedItem / getNamedItemNS unchanged
  • Compliance / unit guard; php-src-strict; no php-compiler-strict shortcut

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:vmVirtual machinebugSomething isn't workingimplementation-readySpec complete: repro, php-src ref, done-when — safe for workers to claimphase-4:stdlibPhase 4 – stdlib for web appsstdlib

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions