@@ -154,6 +154,7 @@ static xmlAttrPtr dom_element_reflected_attribute_write(dom_object *obj, zval *n
154154
155155 /* Typed property, so it is a string already */
156156 ZEND_ASSERT (Z_TYPE_P (newval ) == IS_STRING );
157+ php_libxml_invalidate_node_list_cache (obj -> document );
157158 return xmlSetNsProp (nodep , NULL , (const xmlChar * ) name , (const xmlChar * ) Z_STRVAL_P (newval ));
158159}
159160
@@ -542,7 +543,7 @@ static void dom_deep_ns_redef(xmlNodePtr node, xmlNsPtr ns_to_redefine)
542543 efree (worklist );
543544}
544545
545- static bool dom_remove_attribute (xmlNodePtr thisp , xmlNodePtr attrp )
546+ static bool dom_remove_attribute (xmlNodePtr thisp , xmlNodePtr attrp , php_libxml_ref_obj * document )
546547{
547548 ZEND_ASSERT (thisp != NULL );
548549 ZEND_ASSERT (attrp != NULL );
@@ -597,6 +598,7 @@ static bool dom_remove_attribute(xmlNodePtr thisp, xmlNodePtr attrp)
597598 return false;
598599 default : ZEND_UNREACHABLE ();
599600 }
601+ php_libxml_invalidate_node_list_cache (document );
600602 return true;
601603}
602604
@@ -622,7 +624,7 @@ PHP_METHOD(DOMElement, removeAttribute)
622624 RETURN_FALSE ;
623625 }
624626
625- RETURN_BOOL (dom_remove_attribute (nodep , attrp ));
627+ RETURN_BOOL (dom_remove_attribute (nodep , attrp , intern -> document ));
626628}
627629
628630PHP_METHOD (Dom_Element , removeAttribute )
@@ -640,7 +642,7 @@ PHP_METHOD(Dom_Element, removeAttribute)
640642
641643 attrp = dom_get_attribute_or_nsdecl (intern , nodep , BAD_CAST name , name_len );
642644 if (attrp != NULL ) {
643- dom_remove_attribute (nodep , attrp );
645+ dom_remove_attribute (nodep , attrp , intern -> document );
644646 }
645647}
646648/* }}} end dom_element_remove_attribute */
@@ -798,6 +800,7 @@ static void dom_element_remove_attribute_node(INTERNAL_FUNCTION_PARAMETERS, zend
798800 RETURN_FALSE ;
799801 }
800802
803+ php_libxml_invalidate_node_list_cache (intern -> document );
801804 xmlUnlinkNode ((xmlNodePtr ) attrp );
802805
803806 DOM_RET_OBJ ((xmlNodePtr ) attrp , intern );
@@ -1198,6 +1201,7 @@ PHP_METHOD(DOMElement, removeAttributeNS)
11981201 if (nsptr != NULL ) {
11991202 if (xmlStrEqual (BAD_CAST uri , nsptr -> href )) {
12001203 dom_eliminate_ns (nodep , nsptr );
1204+ php_libxml_invalidate_node_list_cache (intern -> document );
12011205 } else {
12021206 return ;
12031207 }
@@ -1212,6 +1216,7 @@ PHP_METHOD(DOMElement, removeAttributeNS)
12121216 } else {
12131217 xmlUnlinkNode ((xmlNodePtr ) attrp );
12141218 }
1219+ php_libxml_invalidate_node_list_cache (intern -> document );
12151220 }
12161221}
12171222/* }}} end dom_element_remove_attribute_ns */
@@ -1947,7 +1952,7 @@ PHP_METHOD(DOMElement, toggleAttribute)
19471952
19481953 /* Step 5 */
19491954 if (force_is_null || !force ) {
1950- retval = !dom_remove_attribute (thisp , attribute );
1955+ retval = !dom_remove_attribute (thisp , attribute , intern -> document );
19511956 goto out ;
19521957 }
19531958
0 commit comments