Skip to content

Commit

Permalink
Fix phpGH-15534: Bump minimum libxml2 version to 2.9.4 (php#15536)
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
petk and cmb69 authored Aug 23, 2024
1 parent 2cbde5a commit dc8f18a
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 8 deletions.
3 changes: 3 additions & 0 deletions UPGRADING
Original file line number Diff line number Diff line change
Expand Up @@ -871,6 +871,9 @@ PHP 8.4 UPGRADE NOTES
$domain name is empty or too long, and if $variant is not
INTL_IDNA_VARIANT_UTS46.

- LibXML:
. The libxml extension now requires at least libxml2 2.9.4.

- MBString:
. Unicode data tables have been updated to Unicode 15.1.

Expand Down
2 changes: 1 addition & 1 deletion UPGRADING.INTERNALS
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ PHP 8.4 INTERNALS UPGRADE NOTES
- M4 macro PHP_EVAL_LIBLINE got a new 3rd argument to override the ext_shared
checks.
- M4 macro PHP_SETUP_LIBXML doesn't define the redundant HAVE_LIBXML symbol
anymore.
anymore and requires at least libxml2 2.9.4.
- M4 macro PHP_SETUP_ICONV doesn't define the HAVE_ICONV symbol anymore.
- M4 macro PHP_OUTPUT is obsolete (use AC_CONFIG_FILES).
- M4 macro PHP_PROG_SETUP now accepts an argument to set the minimum required
Expand Down
2 changes: 1 addition & 1 deletion build/php.m4
Original file line number Diff line number Diff line change
Expand Up @@ -1912,7 +1912,7 @@ dnl
dnl Common setup macro for libxml.
dnl
AC_DEFUN([PHP_SETUP_LIBXML], [
PKG_CHECK_MODULES([LIBXML], [libxml-2.0 >= 2.9.0])
PKG_CHECK_MODULES([LIBXML], [libxml-2.0 >= 2.9.4])
PHP_EVAL_INCLINE([$LIBXML_CFLAGS])
PHP_EVAL_LIBLINE([$LIBXML_LIBS], [$1])
$2
Expand Down
18 changes: 12 additions & 6 deletions ext/libxml/config.w32
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,19 @@ if (PHP_LIBXML == "yes") {
CHECK_HEADER_ADD_INCLUDE("libxml/tree.h", "CFLAGS_LIBXML", PHP_PHP_BUILD + "\\include\\libxml2") &&
ADD_EXTENSION_DEP('libxml', 'iconv')) {

EXTENSION("libxml", "libxml.c mime_sniff.c", false /* never shared */, "/DZEND_ENABLE_STATIC_TSRMLS_CACHE=1");
AC_DEFINE("HAVE_LIBXML", 1, "Define to 1 if the PHP extension 'libxml' is available.");
ADD_FLAG("CFLAGS_LIBXML", "/D LIBXML_STATIC /D LIBXML_STATIC_FOR_DLL /D HAVE_WIN32_THREADS ");
if (!PHP_LIBXML_SHARED) {
ADD_DEF_FILE("ext\\libxml\\php_libxml2.def");
if (GREP_HEADER("libxml/xmlversion.h", "#define\\s+LIBXML_VERSION\\s+(\\d+)", PHP_PHP_BUILD + "\\include\\libxml2") &&
+RegExp.$1 >= 20904) {

EXTENSION("libxml", "libxml.c mime_sniff.c", false /* never shared */, "/DZEND_ENABLE_STATIC_TSRMLS_CACHE=1");
AC_DEFINE("HAVE_LIBXML", 1, "Define to 1 if the PHP extension 'libxml' is available.");
ADD_FLAG("CFLAGS_LIBXML", "/D LIBXML_STATIC /D LIBXML_STATIC_FOR_DLL /D HAVE_WIN32_THREADS ");
if (!PHP_LIBXML_SHARED) {
ADD_DEF_FILE("ext\\libxml\\php_libxml2.def");
}
PHP_INSTALL_HEADERS("ext/libxml", "php_libxml.h");
} else {
WARNING("libxml support can't be enabled, libxml version >= 2.9.4 required");
}
PHP_INSTALL_HEADERS("ext/libxml", "php_libxml.h");
} else {
WARNING("libxml support can't be enabled, iconv or libxml are missing")
PHP_LIBXML = "no"
Expand Down

0 comments on commit dc8f18a

Please sign in to comment.