diff --git a/UPGRADING.INTERNALS b/UPGRADING.INTERNALS index 6db2d99ec59b9..b1a9188748fad 100644 --- a/UPGRADING.INTERNALS +++ b/UPGRADING.INTERNALS @@ -134,6 +134,8 @@ PHP 8.3 INTERNALS UPGRADE NOTES the base node of the node list. This function also no longer accepts -1 as the index argument. - The function dom_namednode_iter() has additional arguments to avoid recomputing the length of the strings. + - The functions dom_parent_node_prepend(), dom_parent_node_append(), dom_parent_node_after(), and + dom_parent_node_before() now use an uint32_t argument for the number of nodes instead of int. g. ext/libxml - Two new functions: php_libxml_invalidate_node_list_cache_from_doc() and diff --git a/ext/dom/characterdata.c b/ext/dom/characterdata.c index 85660a7b3549f..2ff65a314d3e6 100644 --- a/ext/dom/characterdata.c +++ b/ext/dom/characterdata.c @@ -364,7 +364,7 @@ PHP_METHOD(DOMCharacterData, remove) PHP_METHOD(DOMCharacterData, after) { - int argc; + uint32_t argc; zval *args, *id; dom_object *intern; xmlNode *context; @@ -381,7 +381,7 @@ PHP_METHOD(DOMCharacterData, after) PHP_METHOD(DOMCharacterData, before) { - int argc; + uint32_t argc; zval *args, *id; dom_object *intern; xmlNode *context; @@ -398,7 +398,7 @@ PHP_METHOD(DOMCharacterData, before) PHP_METHOD(DOMCharacterData, replaceWith) { - int argc; + uint32_t argc; zval *args, *id; dom_object *intern; xmlNode *context; diff --git a/ext/dom/document.c b/ext/dom/document.c index 7dd1e7f38ac80..0660fa779e537 100644 --- a/ext/dom/document.c +++ b/ext/dom/document.c @@ -2104,7 +2104,7 @@ Since: DOM Living Standard (DOM4) */ PHP_METHOD(DOMDocument, append) { - int argc; + uint32_t argc; zval *args, *id; dom_object *intern; xmlNode *context; @@ -2125,7 +2125,7 @@ Since: DOM Living Standard (DOM4) */ PHP_METHOD(DOMDocument, prepend) { - int argc; + uint32_t argc; zval *args, *id; dom_object *intern; xmlNode *context; diff --git a/ext/dom/documentfragment.c b/ext/dom/documentfragment.c index 4e7f76a7de80a..a3394e88d5566 100644 --- a/ext/dom/documentfragment.c +++ b/ext/dom/documentfragment.c @@ -135,7 +135,7 @@ Since: DOM Living Standard (DOM4) */ PHP_METHOD(DOMDocumentFragment, append) { - int argc; + uint32_t argc; zval *args, *id; dom_object *intern; xmlNode *context; @@ -156,7 +156,7 @@ Since: DOM Living Standard (DOM4) */ PHP_METHOD(DOMDocumentFragment, prepend) { - int argc; + uint32_t argc; zval *args, *id; dom_object *intern; xmlNode *context; diff --git a/ext/dom/element.c b/ext/dom/element.c index 9b8fe667707fd..8faf77e8440c9 100644 --- a/ext/dom/element.c +++ b/ext/dom/element.c @@ -1155,7 +1155,7 @@ PHP_METHOD(DOMElement, remove) PHP_METHOD(DOMElement, after) { - int argc; + uint32_t argc; zval *args, *id; dom_object *intern; xmlNode *context; @@ -1172,7 +1172,7 @@ PHP_METHOD(DOMElement, after) PHP_METHOD(DOMElement, before) { - int argc; + uint32_t argc; zval *args, *id; dom_object *intern; xmlNode *context; @@ -1192,7 +1192,7 @@ Since: DOM Living Standard (DOM4) */ PHP_METHOD(DOMElement, append) { - int argc; + uint32_t argc; zval *args, *id; dom_object *intern; xmlNode *context; @@ -1213,7 +1213,7 @@ Since: DOM Living Standard (DOM4) */ PHP_METHOD(DOMElement, prepend) { - int argc; + uint32_t argc; zval *args, *id; dom_object *intern; xmlNode *context; @@ -1234,7 +1234,7 @@ Since: DOM Living Standard (DOM4) */ PHP_METHOD(DOMElement, replaceWith) { - int argc; + uint32_t argc; zval *args, *id; dom_object *intern; xmlNode *context; diff --git a/ext/dom/parentnode.c b/ext/dom/parentnode.c index 555296e2ec358..70a952935cac2 100644 --- a/ext/dom/parentnode.c +++ b/ext/dom/parentnode.c @@ -124,9 +124,9 @@ int dom_parent_node_child_element_count(dom_object *obj, zval *retval) } /* }}} */ -static bool dom_is_node_in_list(const zval *nodes, int nodesc, const xmlNodePtr node_to_find) +static bool dom_is_node_in_list(const zval *nodes, uint32_t nodesc, const xmlNodePtr node_to_find) { - for (int i = 0; i < nodesc; i++) { + for (uint32_t i = 0; i < nodesc; i++) { if (Z_TYPE(nodes[i]) == IS_OBJECT) { const zend_class_entry *ce = Z_OBJCE(nodes[i]); @@ -141,9 +141,8 @@ static bool dom_is_node_in_list(const zval *nodes, int nodesc, const xmlNodePtr return false; } -xmlNode* dom_zvals_to_fragment(php_libxml_ref_obj *document, xmlNode *contextNode, zval *nodes, int nodesc) +xmlNode* dom_zvals_to_fragment(php_libxml_ref_obj *document, xmlNode *contextNode, zval *nodes, uint32_t nodesc) { - int i; xmlDoc *documentNode; xmlNode *fragment; xmlNode *newNode; @@ -170,7 +169,7 @@ xmlNode* dom_zvals_to_fragment(php_libxml_ref_obj *document, xmlNode *contextNod stricterror = dom_get_strict_error(document); - for (i = 0; i < nodesc; i++) { + for (uint32_t i = 0; i < nodesc; i++) { if (Z_TYPE(nodes[i]) == IS_OBJECT) { ce = Z_OBJCE(nodes[i]); @@ -253,9 +252,9 @@ static void dom_fragment_assign_parent_node(xmlNodePtr parentNode, xmlNodePtr fr fragment->last = NULL; } -static zend_result dom_hierarchy_node_list(xmlNodePtr parentNode, zval *nodes, int nodesc) +static zend_result dom_hierarchy_node_list(xmlNodePtr parentNode, zval *nodes, uint32_t nodesc) { - for (int i = 0; i < nodesc; i++) { + for (uint32_t i = 0; i < nodesc; i++) { if (Z_TYPE(nodes[i]) == IS_OBJECT) { const zend_class_entry *ce = Z_OBJCE(nodes[i]); @@ -270,7 +269,7 @@ static zend_result dom_hierarchy_node_list(xmlNodePtr parentNode, zval *nodes, i return SUCCESS; } -void dom_parent_node_append(dom_object *context, zval *nodes, int nodesc) +void dom_parent_node_append(dom_object *context, zval *nodes, uint32_t nodesc) { xmlNode *parentNode = dom_object_get_node(context); xmlNodePtr newchild, prevsib; @@ -311,7 +310,7 @@ void dom_parent_node_append(dom_object *context, zval *nodes, int nodesc) xmlFree(fragment); } -void dom_parent_node_prepend(dom_object *context, zval *nodes, int nodesc) +void dom_parent_node_prepend(dom_object *context, zval *nodes, uint32_t nodesc) { xmlNode *parentNode = dom_object_get_node(context); @@ -379,7 +378,7 @@ static void dom_pre_insert(xmlNodePtr insertion_point, xmlNodePtr parentNode, xm } } -void dom_parent_node_after(dom_object *context, zval *nodes, int nodesc) +void dom_parent_node_after(dom_object *context, zval *nodes, uint32_t nodesc) { /* Spec link: https://dom.spec.whatwg.org/#dom-childnode-after */ @@ -432,7 +431,7 @@ void dom_parent_node_after(dom_object *context, zval *nodes, int nodesc) xmlFree(fragment); } -void dom_parent_node_before(dom_object *context, zval *nodes, int nodesc) +void dom_parent_node_before(dom_object *context, zval *nodes, uint32_t nodesc) { /* Spec link: https://dom.spec.whatwg.org/#dom-childnode-before */ @@ -544,7 +543,7 @@ void dom_child_node_remove(dom_object *context) php_dom_throw_error(NOT_FOUND_ERR, stricterror); } -void dom_child_replace_with(dom_object *context, zval *nodes, int nodesc) +void dom_child_replace_with(dom_object *context, zval *nodes, uint32_t nodesc) { xmlNodePtr child = dom_object_get_node(context); xmlNodePtr parentNode = child->parent; diff --git a/ext/dom/php_dom.h b/ext/dom/php_dom.h index 9e01a2ca63964..49e23213157d6 100644 --- a/ext/dom/php_dom.h +++ b/ext/dom/php_dom.h @@ -135,12 +135,12 @@ xmlNode *php_dom_libxml_notation_iter(xmlHashTable *ht, int index); zend_object_iterator *php_dom_get_iterator(zend_class_entry *ce, zval *object, int by_ref); void dom_set_doc_classmap(php_libxml_ref_obj *document, zend_class_entry *basece, zend_class_entry *ce); -void dom_parent_node_prepend(dom_object *context, zval *nodes, int nodesc); -void dom_parent_node_append(dom_object *context, zval *nodes, int nodesc); -void dom_parent_node_after(dom_object *context, zval *nodes, int nodesc); -void dom_parent_node_before(dom_object *context, zval *nodes, int nodesc); +void dom_parent_node_prepend(dom_object *context, zval *nodes, uint32_t nodesc); +void dom_parent_node_append(dom_object *context, zval *nodes, uint32_t nodesc); +void dom_parent_node_after(dom_object *context, zval *nodes, uint32_t nodesc); +void dom_parent_node_before(dom_object *context, zval *nodes, uint32_t nodesc); void dom_child_node_remove(dom_object *context); -void dom_child_replace_with(dom_object *context, zval *nodes, int nodesc); +void dom_child_replace_with(dom_object *context, zval *nodes, uint32_t nodesc); #define DOM_GET_OBJ(__ptr, __id, __prtype, __intern) { \ __intern = Z_DOMOBJ_P(__id); \