1--TEST--
2Delayed freeing namespace definition should not crash in attribute
3--EXTENSIONS--
4dom
5--FILE--
6<?php
7$doc = new DOMDocument;
8$doc->appendChild($doc->createElement('container'));
9$child = $doc->documentElement->appendChild($doc->createElementNS('some:ns', 'child'));
10$child_attr1 = $child->appendChild($doc->createAttributeNS('some:ns2', 'hello'));
11$child_attr1->textContent = 'hello content 1';
12$child_attr2 = $child->appendChild($doc->createAttribute('hello2'));
13$child_attr1->textContent = 'hello content 2';
14$attr3 = $child->appendChild($doc->createElementNS('some:ns', 'childcontainer'))
15        ->appendChild($doc->createAttributeNS('some:ns', 'hello'));
16
17echo $doc->saveXML();
18
19$child->remove();
20echo $doc->saveXML();
21
22unset($child);
23
24var_dump($child_attr1->textContent);
25var_dump($child_attr2->textContent);
26var_dump($child_attr1->namespaceURI);
27var_dump($child_attr2->namespaceURI);
28var_dump($attr3->textContent);
29var_dump($attr3->namespaceURI);
30
31$doc->documentElement->remove();
32
33unset($child_attr1);
34unset($child_attr2);
35var_dump($attr3->namespaceURI);
36
37echo $doc->saveXML($attr3), "\n";
38echo $doc->saveXML($attr3->parentNode), "\n";
39?>
40--EXPECT--
41<?xml version="1.0"?>
42<container xmlns:default="some:ns2" xmlns:default1="some:ns"><child xmlns="some:ns" default:hello="hello content 2" hello2=""><childcontainer default1:hello=""/></child></container>
43<?xml version="1.0"?>
44<container xmlns:default="some:ns2" xmlns:default1="some:ns"/>
45string(15) "hello content 2"
46string(0) ""
47string(8) "some:ns2"
48NULL
49string(0) ""
50string(7) "some:ns"
51string(7) "some:ns"
52 default1:hello=""
53<?xml version="1.0"?>
54