Skip to content

Commit 44af9ad

Browse files
authored
Drop LIBXML_HTML_ENABLED checks (#20083)
It is possible to build libxml without HTML support, which would mean that PHP does not support the saveHtml() features and HTML parsing in general. It also adds some maintenance complexity. I'm not aware of any distro that does this and it shows: this has been broken since stubs have been introduced. So we can just drop it as clearly no one cares about this or we would've known about it already. It also simplifies downstream code because they can now rely on the HTML functionality to always be available.
1 parent 18d99ee commit 44af9ad

File tree

5 files changed

+3
-35
lines changed

5 files changed

+3
-35
lines changed

ext/dom/document.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2040,8 +2040,6 @@ PHP_METHOD(DOMDocument, relaxNGValidateSource)
20402040

20412041
#endif
20422042

2043-
#ifdef LIBXML_HTML_ENABLED
2044-
20452043
static void dom_load_html(INTERNAL_FUNCTION_PARAMETERS, int mode) /* {{{ */
20462044
{
20472045
char *source;
@@ -2234,8 +2232,6 @@ PHP_METHOD(DOMDocument, saveHTML)
22342232
}
22352233
/* }}} end dom_document_save_html */
22362234

2237-
#endif /* defined(LIBXML_HTML_ENABLED) */
2238-
22392235
/* {{{ Register extended class used to create base node type */
22402236
static void dom_document_register_node_class(INTERNAL_FUNCTION_PARAMETERS, bool modern)
22412237
{

ext/dom/php_dom.c

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1369,9 +1369,7 @@ PHP_MINFO_FUNCTION(dom)
13691369
php_info_print_table_row(2, "DOM/XML", "enabled");
13701370
php_info_print_table_row(2, "DOM/XML API Version", DOM_API_VERSION);
13711371
php_info_print_table_row(2, "libxml Version", LIBXML_DOTTED_VERSION);
1372-
#ifdef LIBXML_HTML_ENABLED
13731372
php_info_print_table_row(2, "HTML Support", "enabled");
1374-
#endif
13751373
#ifdef LIBXML_XPATH_ENABLED
13761374
php_info_print_table_row(2, "XPath Support", "enabled");
13771375
#endif
@@ -2709,20 +2707,10 @@ xmlChar *php_dom_libxml_fix_file_path(xmlChar *path)
27092707

27102708
xmlDocPtr php_dom_create_html_doc(void)
27112709
{
2712-
#ifdef LIBXML_HTML_ENABLED
27132710
xmlDocPtr lxml_doc = htmlNewDocNoDtD(NULL, NULL);
27142711
if (EXPECTED(lxml_doc)) {
27152712
lxml_doc->dict = xmlDictCreate();
27162713
}
2717-
#else
2718-
/* If HTML support is not enabled, then htmlNewDocNoDtD() is not available.
2719-
* This code mimics the behaviour. */
2720-
xmlDocPtr lxml_doc = xmlNewDoc((const xmlChar *) "1.0");
2721-
if (EXPECTED(lxml_doc)) {
2722-
lxml_doc->type = XML_HTML_DOCUMENT_NODE;
2723-
lxml_doc->dict = xmlDictCreate();
2724-
}
2725-
#endif
27262714
return lxml_doc;
27272715
}
27282716

ext/dom/php_dom.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,8 @@ extern zend_module_entry dom_module_entry;
3434
#include <libxml/xinclude.h>
3535
#include <libxml/hash.h>
3636
#include <libxml/c14n.h>
37-
#ifdef LIBXML_HTML_ENABLED
3837
#include <libxml/HTMLparser.h>
3938
#include <libxml/HTMLtree.h>
40-
#endif
4139
#ifdef LIBXML_XPATH_ENABLED
4240
#include <libxml/xpath.h>
4341
#include <libxml/xpathInternals.h>

ext/dom/php_dom.stub.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1013,7 +1013,6 @@ public function registerNodeClass(string $baseClass, ?string $extendedClass): tr
10131013
/** @tentative-return-type */
10141014
public function save(string $filename, int $options = 0): int|false {}
10151015

1016-
#ifdef LIBXML_HTML_ENABLED
10171016
/** @tentative-return-type */
10181017
public function loadHTML(string $source, int $options = 0): bool {}
10191018

@@ -1025,7 +1024,6 @@ public function saveHTML(?DOMNode $node = null): string|false {}
10251024

10261025
/** @tentative-return-type */
10271026
public function saveHTMLFile(string $filename): int|false {}
1028-
#endif
10291027

10301028
/** @tentative-return-type */
10311029
public function saveXML(?DOMNode $node = null, int $options = 0): string|false {}

ext/dom/php_dom_arginfo.h

Lines changed: 3 additions & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)