Skip to content

Regression: DOMException NOT_FOUND_ERR code is 0 — Zend code 8 (ext/dom/php_dom.c) #22694

Closed

Description

@PurHur

Category

stdlib · php-src-strict · DOMException codes (pillar 4)

Problem

Double-removeChild of an already-detached node must throw DOMException with Zend message Not Found Error and code 8 (DOM_NOT_FOUND_ERR). The VM throws a near message (Not found error) but $e->getCode() is 0.

DOM_NOT_FOUND_ERR constant is correctly 8 on both engines — only the exception instance code (and message casing) is wrong. Sibling of open #22658 (WRONG_DOCUMENT_ERR code 0 vs 4); fix shared DOMException construction so all DOM error codes propagate.

Probed 2026-07-23 on master VM vs host Zend 8.2.32.

Repro Zend 8.2+ VM (2026-07-23)
second removeChild($a) after detach DOMException msg Not Found Error, code 8 msg Not found error, code 0
DOM_NOT_FOUND_ERR 8 8

php-src reference

PHP implementation target

Repro

./script/docker-exec.sh -- bash -lc 'php bin/vm.php -r '"'"'
$d = new DOMDocument();
$d->loadXML("<r><a/></r>");
$a = $d->documentElement->firstChild;
$d->documentElement->removeChild($a);
try {
  $d->documentElement->removeChild($a);
  echo "no throw\n";
} catch (DOMException $e) {
  echo "msg=", $e->getMessage(), " code=", $e->getCode(), "\n";
}
echo "DOM_NOT_FOUND_ERR=", DOM_NOT_FOUND_ERR, "\n";
'"'"''

Done when

Activity

  1. added
    bugSomething isn't working
    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 23, 2026
  2. PurHur commented on Jul 23, 2026

    @PurHur
    OwnerAuthor

    Sibling DOMException code gap: #22658 (WRONG_DOCUMENT_ERR code 0 vs 4). Prefer one shared DOMException constructor fix. Gate probe: see #22691 comment.

  3. PurHur commented on Jul 23, 2026

    @PurHur
    OwnerAuthor

    claim: PHP Compiler STD Lib — fixing with shared DomExceptionConstants helper in same PR as #22658 (raiseNotFound / raiseWrongDocument).

  4. PurHur commented on Jul 23, 2026

    @PurHur
    OwnerAuthor

    Merged via PR #22712 (shared helper with #22658).

    Double-removeChild now throws Not Found Error with code 8 on VM/JIT.

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