Skip to content

Stdlib: DOMElement::compareDocumentPosition() undefined — sibling order bit checks missing (ext/dom/node.c) #17696

Closed

Description

@PurHur

Category

stdlib · php-src-strict · DOM Level 3 node ordering

Problem

Zend exposes DOMElement::compareDocumentPosition() for document-order bitmask checks (DOMNode::DOCUMENT_POSITION_*). This compiler fatals with Call to undefined method DOMElement::compareDocumentPosition() on the same snippet.

Verified 2026-07-10 on master (reference profile).

Repro Zend 8.2+ VM (2026-07-10)
$parent->compareDocumentPosition($sibling) & DOCUMENT_POSITION_FOLLOWING bitmask with FOLLOWING set Error: Call to undefined method DOMElement::compareDocumentPosition()

php-src reference

PHP implementation target

  • ext/dom/ instance method lowering for compareDocumentPosition in PHP (lib/JIT/Builtin/Dom* as needed); thin C ABI only if unavoidable
  • Shared DOM node handle path with existing DOMNode methods; VM + JIT/AOT agree

Repro

./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && php bin/vm.php test/repro/maintainer_gap_dom_compare_document_position_sibling.php'
# Fatal undefined method — Zend prints ok

Done when

  • test/repro/maintainer_gap_dom_compare_document_position_sibling.php prints ok on VM/JIT/AOT
  • Compliance .phpt guard under test/compliance/cases/dom/compare_document_position_sibling.phpt
  • php-src-strict; no php-compiler-strict shortcut

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

    @PurHur
    OwnerAuthor

    claim: PHP Compiler Ext — DOM & XML — starting this run

  3. PurHur commented on Jul 10, 2026

    @PurHur
    OwnerAuthor

    Merged via #17779.

    Root cause: compareDocumentPosition was incorrectly gated behind supportsDomApiSince('8.4.0') even though it is DOM Level 3 (php-src ext/dom/node.c), available on Zend 8.0+ reference profile.

    Fix: supportsDomNodeCompareDocumentPosition() now returns true; removed SKIPIF/phantom guards for this method.

    Verification:

    source script/php-env.sh
    php bin/vm.php test/repro/maintainer_gap_dom_compare_document_position_sibling.php   # ok
    php bin/jit.php test/repro/maintainer_gap_dom_compare_document_position_sibling.php  # ok
    php vendor/bin/phpunit test/unit/DomModuleTest.php --filter test_dom_node_compare_document_position --no-configuration  # OK
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