Skip to content

Regression: DOMElement::getAttributeNS()/hasAttributeNS() — setAttributeNS values invisible (ext/dom/element.c) #15380

Closed

Description

@PurHur

Category

stdlib · php-src-strict · DOM namespace attribute regression

Problem

After DOMElement::setAttributeNS($namespace, $qualifiedName, $value), Zend returns the stored value from getAttributeNS($namespace, $localName) and hasAttributeNS() is true. On bin/vm.php, getAttributeNS() returns an empty string and hasAttributeNS() is false even though getAttribute($localName) still sees the value.

Verified 2026-07-03 on master.

php-src reference

PHP implementation target

  • ext/dom/VmDom.php — getAttributeNS() / hasAttributeNSExact() must resolve attribute namespace from the element’s in-scope namespaces (including default NS from createElementNS()), not only xmlns:* declarations
  • Wire through existing ElementGetAttributeNS.php / ElementHasAttributeNS.php builtins
  • PHP-in-PHP first; no new C runtime logic

Repro (verified 2026-07-03)

./script/docker-exec.sh -- bash -lc 'php test/repro/maintainer_gap_dom_get_attribute_ns.php'      # Zend: ok
./script/docker-exec.sh -- bash -lc 'php bin/vm.php test/repro/maintainer_gap_dom_get_attribute_ns.php'  # fail exit 1

Repro: test/repro/maintainer_gap_dom_get_attribute_ns.php

Runtime getAttributeNS(..., 'attr') hasAttributeNS(..., 'attr')
Zend v true
bin/vm.php '' false

Done when

  • setAttributeNS + getAttributeNS / hasAttributeNS round-trip for prefixed attributes on NS-qualified elements
  • removeAttributeNS still works (already green on repro path)
  • Repro exits 0; compliance guard under test/compliance/cases/stdlib/dom_*

Related

Activity

  1. added
    enhancementNew feature or request
    phase-4:stdlibPhase 4 – stdlib for web apps
    area:vmVirtual machine
    implementation-readySpec complete: repro, php-src ref, done-when — safe for workers to claim
    on Jul 3, 2026
  2. PurHur commented on Jul 3, 2026

    @PurHur
    OwnerAuthor

    claim: PHP Compiler STD Lib Advanced — batch (issues #15380, #15381, #15345)

  3. PurHur commented on Jul 3, 2026

    @PurHur
    OwnerAuthor

    Merged in #15394 — setAttributeNS + getAttributeNS/hasAttributeNS round-trip on createElementNS elements verified via repro + compliance.

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 machineenhancementNew feature or requestimplementation-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