Skip to content

Stdlib: DOMDocument::getElementById() missing — ID lookup fatal (ext/dom/php_dom.c) #14378

Closed

Description

@PurHur

Summary

DOMDocument::getElementById(string $elementId): ?DOMElement is part of the ext/dom API in php-src. VM fatals with undefined method DOMDocument::getElementById(); Zend PHP 8.2 in Docker runs the method (returns null when no DTD/id map, or the matching element when configured).

php-src reference

  • ext/dom/php_dom.c — dom_document_get_element_by_id
  • ext/dom/document.stub.php — DOMDocument::getElementById

PHP implementation target

  • ext/dom/VmDom.php + DOM document wrappers (not new C runtime logic)
  • Wire libxml ID table when validateOnParse/DTD present; return null when unknown id (Zend parity)

Repro

./script/docker-exec.sh -- php bin/vm.php test/repro/maintainer_gap_dom_get_element_by_id.php
# VM: undefined method DOMDocument::getElementById()
# Zend 8.2: ok (prints null or ok depending on id map)

Expected (php-src-strict)

  • Method registered on DOMDocument
  • Known id in loaded document → DOMElement; unknown → null
  • No fatal for method dispatch

Done when

  • Repro green on VM
  • ID lookup matches Zend for DTD and non-DTD documents
  • Shared VM path; JIT/AOT documented if stubbed

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 1, 2026
  2. PurHur commented on Jul 1, 2026

    @PurHur
    OwnerAuthor

    Merged via #14384.

    Verification

    php bin/vm.php test/repro/maintainer_gap_dom_get_element_by_id.php       # null / missing_null
    php bin/vm.php test/repro/maintainer_gap_dom_get_element_by_id_dtd.php  # dtd_ok
    ./vendor/bin/phpunit --filter dom_get_element_by_id                     # OK (4 tests)
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