Skip to content

Commit dc8f18a

Browse files
petkcmb69
andauthored
Fix GH-15534: Bump minimum libxml2 version to 2.9.4 (#15536)
The xmlDictPtr was moved before the includes in libxml2 2.9.4 so the <libxml/dict.h> can be included directly but for earlier versions the <libxml/tree.h> needs to be included before. Since PHP requires libxml2 2.9.0 or later and this also fixes builds on Solaris 10. As earlier 2.9.0-2.9.3 libxml2 versions also include several security issues, this change bumps the required minimum libxml2 version to 2.9.4 On Windows, a check for minimum libxml2 version is also added. Co-authored-by: Christoph M. Becker <[email protected]>
1 parent 2cbde5a commit dc8f18a

File tree

4 files changed

+17
-8
lines changed

4 files changed

+17
-8
lines changed

UPGRADING

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -871,6 +871,9 @@ PHP 8.4 UPGRADE NOTES
871871
$domain name is empty or too long, and if $variant is not
872872
INTL_IDNA_VARIANT_UTS46.
873873

874+
- LibXML:
875+
. The libxml extension now requires at least libxml2 2.9.4.
876+
874877
- MBString:
875878
. Unicode data tables have been updated to Unicode 15.1.
876879

UPGRADING.INTERNALS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ PHP 8.4 INTERNALS UPGRADE NOTES
178178
- M4 macro PHP_EVAL_LIBLINE got a new 3rd argument to override the ext_shared
179179
checks.
180180
- M4 macro PHP_SETUP_LIBXML doesn't define the redundant HAVE_LIBXML symbol
181-
anymore.
181+
anymore and requires at least libxml2 2.9.4.
182182
- M4 macro PHP_SETUP_ICONV doesn't define the HAVE_ICONV symbol anymore.
183183
- M4 macro PHP_OUTPUT is obsolete (use AC_CONFIG_FILES).
184184
- M4 macro PHP_PROG_SETUP now accepts an argument to set the minimum required

build/php.m4

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1912,7 +1912,7 @@ dnl
19121912
dnl Common setup macro for libxml.
19131913
dnl
19141914
AC_DEFUN([PHP_SETUP_LIBXML], [
1915-
PKG_CHECK_MODULES([LIBXML], [libxml-2.0 >= 2.9.0])
1915+
PKG_CHECK_MODULES([LIBXML], [libxml-2.0 >= 2.9.4])
19161916
PHP_EVAL_INCLINE([$LIBXML_CFLAGS])
19171917
PHP_EVAL_LIBLINE([$LIBXML_LIBS], [$1])
19181918
$2

ext/libxml/config.w32

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,19 @@ if (PHP_LIBXML == "yes") {
99
CHECK_HEADER_ADD_INCLUDE("libxml/tree.h", "CFLAGS_LIBXML", PHP_PHP_BUILD + "\\include\\libxml2") &&
1010
ADD_EXTENSION_DEP('libxml', 'iconv')) {
1111

12-
EXTENSION("libxml", "libxml.c mime_sniff.c", false /* never shared */, "/DZEND_ENABLE_STATIC_TSRMLS_CACHE=1");
13-
AC_DEFINE("HAVE_LIBXML", 1, "Define to 1 if the PHP extension 'libxml' is available.");
14-
ADD_FLAG("CFLAGS_LIBXML", "/D LIBXML_STATIC /D LIBXML_STATIC_FOR_DLL /D HAVE_WIN32_THREADS ");
15-
if (!PHP_LIBXML_SHARED) {
16-
ADD_DEF_FILE("ext\\libxml\\php_libxml2.def");
12+
if (GREP_HEADER("libxml/xmlversion.h", "#define\\s+LIBXML_VERSION\\s+(\\d+)", PHP_PHP_BUILD + "\\include\\libxml2") &&
13+
+RegExp.$1 >= 20904) {
14+
15+
EXTENSION("libxml", "libxml.c mime_sniff.c", false /* never shared */, "/DZEND_ENABLE_STATIC_TSRMLS_CACHE=1");
16+
AC_DEFINE("HAVE_LIBXML", 1, "Define to 1 if the PHP extension 'libxml' is available.");
17+
ADD_FLAG("CFLAGS_LIBXML", "/D LIBXML_STATIC /D LIBXML_STATIC_FOR_DLL /D HAVE_WIN32_THREADS ");
18+
if (!PHP_LIBXML_SHARED) {
19+
ADD_DEF_FILE("ext\\libxml\\php_libxml2.def");
20+
}
21+
PHP_INSTALL_HEADERS("ext/libxml", "php_libxml.h");
22+
} else {
23+
WARNING("libxml support can't be enabled, libxml version >= 2.9.4 required");
1724
}
18-
PHP_INSTALL_HEADERS("ext/libxml", "php_libxml.h");
1925
} else {
2026
WARNING("libxml support can't be enabled, iconv or libxml are missing")
2127
PHP_LIBXML = "no"

0 commit comments

Comments
 (0)