From 21c1fb6a67adec61c89d34ae60fe0c9c103a0041 Mon Sep 17 00:00:00 2001 From: Niels Dossche <7771979+nielsdos@users.noreply.github.com> Date: Tue, 27 Jun 2023 17:46:00 +0200 Subject: [PATCH] Two tiny ext/dom cleanups (#11541) * Remove obsolete workaround code This code was for libxml2 <= 2.6.14. PHP requires at least libxml2 2.9.0. * Use an inline check instead of calling into the library for an empty string check --- ext/dom/documentfragment.c | 41 -------------------------------------- ext/dom/php_dom.c | 2 +- 2 files changed, 1 insertion(+), 42 deletions(-) diff --git a/ext/dom/documentfragment.c b/ext/dom/documentfragment.c index b52a9c820ba..f3837f2824f 100644 --- a/ext/dom/documentfragment.c +++ b/ext/dom/documentfragment.c @@ -57,42 +57,6 @@ PHP_METHOD(DOMDocumentFragment, __construct) } /* }}} end DOMDocumentFragment::__construct */ -#if LIBXML_VERSION <= 20614 -/* php_dom_xmlSetTreeDoc is a custom implementation of xmlSetTreeDoc - needed for hack in appendXML due to libxml bug - no need to share this function */ -static void php_dom_xmlSetTreeDoc(xmlNodePtr tree, xmlDocPtr doc) /* {{{ */ -{ - xmlAttrPtr prop; - xmlNodePtr cur; - - if (tree) { - if(tree->type == XML_ELEMENT_NODE) { - prop = tree->properties; - while (prop != NULL) { - prop->doc = doc; - if (prop->children) { - cur = prop->children; - while (cur != NULL) { - php_dom_xmlSetTreeDoc(cur, doc); - cur = cur->next; - } - } - prop = prop->next; - } - } - if (tree->children != NULL) { - cur = tree->children; - while (cur != NULL) { - php_dom_xmlSetTreeDoc(cur, doc); - cur = cur->next; - } - } - tree->doc = doc; - } -} -/* }}} */ -#endif - /* {{{ */ PHP_METHOD(DOMDocumentFragment, appendXML) { zval *id; @@ -120,11 +84,6 @@ PHP_METHOD(DOMDocumentFragment, appendXML) { if (err != 0) { RETURN_FALSE; } -#if LIBXML_VERSION <= 20614 - /* Following needed due to bug in libxml2 <= 2.6.14 */ - php_dom_xmlSetTreeDoc(lst, nodep->doc); - /* End stupid hack */ -#endif xmlAddChildList(nodep,lst); } diff --git a/ext/dom/php_dom.c b/ext/dom/php_dom.c index de6239691c6..245a7137fe9 100644 --- a/ext/dom/php_dom.c +++ b/ext/dom/php_dom.c @@ -1636,7 +1636,7 @@ xmlNsPtr dom_get_nsdecl(xmlNode *node, xmlChar *localName) { if (node == NULL) return NULL; - if (localName == NULL || xmlStrEqual(localName, (xmlChar *)"")) { + if (localName == NULL || localName[0] == '\0') { cur = node->nsDef; while (cur != NULL) { if (cur->prefix == NULL && cur->href != NULL) {