Skip to content

DOMNameSpaceNode parent not unset when namespace gets unlinked. #12850

@nielsdos

Description

@nielsdos

Description

The following code:

<?php

$dom = new DOMDocument;
$dom->loadXML("<container xmlns=\"urn:foo\"/>");
$container = $dom->documentElement;
$ns = $container->getAttributeNode("xmlns");

var_dump($ns);

$container->removeAttributeNs("urn:foo", "");

var_dump($ns);

Resulted in this output:

first dump: DOMNameSpaceNode with parent node non-NULL (okay)
second dump: DOMNameSpaceNode with parent node non-NULL (not okay)

But I expected this output instead:

first dump: DOMNameSpaceNode with parent node non-NULL
second dump: DOMNameSpaceNode with parent node NULL

In versions prior to 8.1 the parent node was always NULL.
Mainly creating the issue so I don't forget about this.

PHP Version

8.1+

Operating System

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions