Skip to content

Commit bc7537d

Browse files
committed
ext/libxml: Fix build failure with libxml2 2.15.
libxml2 2.15 removed the built-in HTTP client, the FTP module, the functions in xmlunicode.h, the shell and several other legacy symbols. The Windows export list php_libxml2.def still referenced them, so the statically linked build failed with hundreds of unresolved external symbols. Keep php_libxml2_legacy.def as the original export list, unchanged, and make php_libxml2.def the clean 2.15+ list, selecting one or the other depending on the libxml2 version being built against. Also adjust the ext/dom tests for the 2.15 URI change: drive letters are no longer URI schemes on Windows, so relaxNGValidate() reports a backslash path and xmlns="x:y" is no longer absolute. Fix GH-22752 Close GH-22755
1 parent c4c356a commit bc7537d

11 files changed

Lines changed: 1542 additions & 328 deletions

NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ PHP NEWS
1818
. Fixed bug GH-23120 (Stack overflow when comparing deeply nested DOM nodes
1919
with DOMNode::isEqualNode()). (Weilin Du)
2020

21+
- LibXML:
22+
. Fixed bug GH-22752 (Build failure with libxml 2.15). (David Carlier)
23+
2124
- MBString:
2225
. Fixed bug GH-22779 (mb_strrpos() returns the wrong position for a negative
2326
offset in a non-UTF-8 encoding). (Eyüp Can Akman)

ext/dom/tests/DOMDocument_relaxNGValidate_error2.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ var_dump($result);
2222
--EXPECTF--
2323
Warning: DOMDocument::relaxNGValidate(): I/O %s : failed to load %s
2424

25-
Warning: DOMDocument::relaxNGValidate(): xmlRelaxNGParse: could not load %s/foo.rng in %s on line %d
25+
Warning: DOMDocument::relaxNGValidate(): xmlRelaxNGParse: could not load %sfoo.rng in %s on line %d
2626

2727
Warning: DOMDocument::relaxNGValidate(): Invalid RelaxNG in %s on line %d
2828
bool(false)

ext/dom/tests/modern/html/serializer/HTMLDocument_serialize_ns_imported_02.phpt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ echo $html->saveHtml(), "\n";
2525
<container xmlns="some:ns" xmlns:bar="another:ns">
2626
<x>
2727
<subcontainer>
28-
<test xmlns="x:y"/>
28+
<test xmlns="xy:z"/>
2929
<child2/>
3030
</subcontainer>
3131
<subcontainer2>
@@ -38,7 +38,7 @@ echo $html->saveHtml(), "\n";
3838
<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body><p>foo<container xmlns="some:ns" xmlns:bar="another:ns">
3939
<x>
4040
<subcontainer>
41-
<test xmlns="x:y"/>
41+
<test xmlns="xy:z"/>
4242
<child2/>
4343
</subcontainer>
4444
<subcontainer2>
@@ -49,7 +49,7 @@ echo $html->saveHtml(), "\n";
4949
<html><head></head><body><p>foo<container xmlns="some:ns" xmlns:bar="another:ns">
5050
<x>
5151
<subcontainer>
52-
<test xmlns="x:y"></test>
52+
<test xmlns="xy:z"></test>
5353
<child2></child2>
5454
</subcontainer>
5555
<subcontainer2>

ext/dom/tests/modern/html/serializer/HTMLDocument_serialize_ns_imported_03.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ echo $html->saveHtml(), "\n";
2525
<container xmlns="some:ns" xmlns:bar="another:ns">
2626
<x>
2727
<subcontainer>
28-
<test xmlns="x:y"/>
28+
<test xmlns="xy:z"/>
2929
<child2/>
3030
</subcontainer>
3131
<subcontainer2>

ext/dom/tests/modern/html/serializer/HTMLDocument_serialize_ns_imported_04.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ echo $html->saveHtml(), "\n";
2525
<container xmlns="some:ns" xmlns:bar="another:ns">
2626
<x>
2727
<subcontainer>
28-
<test xmlns="x:y"/>
28+
<test xmlns="xy:z"/>
2929
<child2/>
3030
</subcontainer>
3131
<subcontainer2>

ext/dom/tests/modern/html/serializer/HTMLDocument_serialize_ns_imported_05.phpt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ echo $html->saveHtml(), "\n";
2525
<container xmlns="some:ns" xmlns:bar="another:ns">
2626
<x>
2727
<subcontainer>
28-
<test xmlns="x:y"/>
28+
<test xmlns="xy:z"/>
2929
<child2/>
3030
</subcontainer>
3131
<subcontainer2>
@@ -38,7 +38,7 @@ echo $html->saveHtml(), "\n";
3838
<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body><p>foo<container xmlns="some:ns" xmlns:bar="another:ns">
3939
<x>
4040
<subcontainer>
41-
<test xmlns="x:y"/>
41+
<test xmlns="xy:z"/>
4242
<child2/>
4343
</subcontainer>
4444
<subcontainer2>
@@ -49,7 +49,7 @@ echo $html->saveHtml(), "\n";
4949
<html><head></head><body><p>foo<container xmlns="some:ns" xmlns:bar="another:ns">
5050
<x>
5151
<subcontainer>
52-
<test xmlns="x:y"></test>
52+
<test xmlns="xy:z"></test>
5353
<child2></child2>
5454
</subcontainer>
5555
<subcontainer2>

ext/dom/tests/modern/html/serializer/HTMLDocument_serialize_ns_imported_06.phpt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ echo $html->saveHtml(), "\n";
2525
<container xmlns="some:ns" xmlns:bar="another:ns">
2626
<x>
2727
<subcontainer>
28-
<test xmlns="x:y"/>
28+
<test xmlns="xy:z"/>
2929
<child2/>
3030
</subcontainer>
3131
<subcontainer2>
@@ -37,7 +37,7 @@ echo $html->saveHtml(), "\n";
3737
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
3838
<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body><p>foo<x xmlns="some:ns">
3939
<subcontainer>
40-
<test xmlns="x:y"/>
40+
<test xmlns="xy:z"/>
4141
<child2/>
4242
</subcontainer>
4343
<subcontainer2>
@@ -46,7 +46,7 @@ echo $html->saveHtml(), "\n";
4646
<child xmlns="some:ns2"/></x></p></body></html>
4747
<html><head></head><body><p>foo<x>
4848
<subcontainer>
49-
<test xmlns="x:y"></test>
49+
<test xmlns="xy:z"></test>
5050
<child2></child2>
5151
</subcontainer>
5252
<subcontainer2>

ext/dom/tests/modern/html/serializer/sample.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<container xmlns="some:ns" xmlns:bar="another:ns">
33
<x>
44
<subcontainer>
5-
<test xmlns="x:y" />
5+
<test xmlns="xy:z" />
66
<child2 />
77
</subcontainer>
88
<subcontainer2>

ext/libxml/config.w32

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,19 @@ if (PHP_LIBXML == "yes") {
1212
if (GREP_HEADER("libxml/xmlversion.h", "#define\\s+LIBXML_VERSION\\s+(\\d+)", PHP_PHP_BUILD + "\\include\\libxml2") &&
1313
+RegExp.$1 >= 20904) {
1414

15+
var libxml_ver = +RegExp.$1; /* capture now; RegExp.$1 gets clobbered below */
16+
1517
EXTENSION("libxml", "libxml.c mime_sniff.c", false /* never shared */, "/DZEND_ENABLE_STATIC_TSRMLS_CACHE=1");
1618
AC_DEFINE("HAVE_LIBXML", 1, "Define to 1 if the PHP extension 'libxml' is available.");
1719
ADD_FLAG("CFLAGS_LIBXML", "/D LIBXML_STATIC /D LIBXML_STATIC_FOR_DLL /D HAVE_WIN32_THREADS ");
1820
if (!PHP_LIBXML_SHARED) {
19-
ADD_DEF_FILE("ext\\libxml\\php_libxml2.def");
21+
if (libxml_ver >= 21500) {
22+
/* The HTTP and FTP modules, SAX1, the shell, xmlunicode.h
23+
and various other legacy symbols were removed in 2.15. */
24+
ADD_DEF_FILE("ext\\libxml\\php_libxml2.def");
25+
} else {
26+
ADD_DEF_FILE("ext\\libxml\\php_libxml2_legacy.def");
27+
}
2028
}
2129
PHP_INSTALL_HEADERS("ext/libxml", "php_libxml.h");
2230
} else {

0 commit comments

Comments
 (0)