From dc8f18af0b1b88aac423833b9d48605828113020 Mon Sep 17 00:00:00 2001 From: Peter Kokot Date: Fri, 23 Aug 2024 23:14:38 +0200 Subject: [PATCH] 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 can be included directly but for earlier versions the 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 --- UPGRADING | 3 +++ UPGRADING.INTERNALS | 2 +- build/php.m4 | 2 +- ext/libxml/config.w32 | 18 ++++++++++++------ 4 files changed, 17 insertions(+), 8 deletions(-) diff --git a/UPGRADING b/UPGRADING index e284abc970944..2107a07472584 100644 --- a/UPGRADING +++ b/UPGRADING @@ -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. diff --git a/UPGRADING.INTERNALS b/UPGRADING.INTERNALS index a23cdcf401c9a..85b0da4cf00cc 100644 --- a/UPGRADING.INTERNALS +++ b/UPGRADING.INTERNALS @@ -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 diff --git a/build/php.m4 b/build/php.m4 index 4c4ba44708b7d..442779ba734b4 100644 --- a/build/php.m4 +++ b/build/php.m4 @@ -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 diff --git a/ext/libxml/config.w32 b/ext/libxml/config.w32 index 416ae1f136637..d836f0efcba7f 100644 --- a/ext/libxml/config.w32 +++ b/ext/libxml/config.w32 @@ -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"