Skip to content

Commit 57215ac

Browse files
committed
More invalidations
1 parent 6ca41b7 commit 57215ac

File tree

3 files changed

+47
-0
lines changed

3 files changed

+47
-0
lines changed

ext/dom/node.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,8 @@ int dom_node_node_value_write(dom_object *obj, zval *newval)
195195
break;
196196
}
197197

198+
php_libxml_invalidate_node_list_cache_from_doc(nodep->doc);
199+
198200
zend_string_release_ex(str, 0);
199201
return SUCCESS;
200202
}

ext/dom/processinginstruction.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,8 @@ int dom_processinginstruction_data_write(dom_object *obj, zval *newval)
128128
return FAILURE;
129129
}
130130

131+
php_libxml_invalidate_node_list_cache_from_doc(nodep->doc);
132+
131133
xmlNodeSetContentLen(nodep, (xmlChar *) ZSTR_VAL(str), ZSTR_LEN(str) + 1);
132134

133135
zend_string_release_ex(str, 0);
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
--TEST--
2+
DOMDocument::getElementsByTagName() liveness affected by writing properties
3+
--EXTENSIONS--
4+
dom
5+
--FILE--
6+
<?php
7+
8+
$xml = '<root xmlns:ns1="foo" xmlns:ns2="bar"><ns1:a/></root>';
9+
$fields = ['nodeValue', 'textContent'];
10+
11+
foreach ($fields as $field) {
12+
$doc = new DOMDocument;
13+
$doc->loadXML($xml);
14+
$list = $doc->getElementsByTagName('a');
15+
var_dump($list->item(0) === NULL);
16+
$doc->documentElement->{$field} = 'new_content';
17+
var_dump($list->item(0) === NULL);
18+
print $doc->saveXML();
19+
}
20+
21+
// Shouldn't be affected
22+
$doc = new DOMDocument;
23+
$doc->loadXML($xml);
24+
$list = $doc->getElementsByTagNameNS('foo', 'a');
25+
var_dump($list->item(0) === NULL);
26+
$doc->documentElement->firstChild->prefix = 'ns2';
27+
var_dump($list->item(0) === NULL);
28+
print $doc->saveXML();
29+
30+
?>
31+
--EXPECT--
32+
bool(false)
33+
bool(true)
34+
<?xml version="1.0"?>
35+
<root xmlns:ns1="foo" xmlns:ns2="bar">new_content</root>
36+
bool(false)
37+
bool(true)
38+
<?xml version="1.0"?>
39+
<root xmlns:ns1="foo" xmlns:ns2="bar">new_content</root>
40+
bool(false)
41+
bool(false)
42+
<?xml version="1.0"?>
43+
<root xmlns:ns1="foo" xmlns:ns2="bar"><ns2:a xmlns:ns2="foo"/></root>

0 commit comments

Comments
 (0)