From 6647b8f4d9b578834933ec76b37168d06bc60bcb Mon Sep 17 00:00:00 2001 From: Peter Kokot Date: Thu, 22 Aug 2024 02:28:47 +0200 Subject: [PATCH 1/5] Fix GH-15534: Build failure for libxml2 2.9.0 - 2.9.3 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. --- ext/dom/lexbor/lexbor/selectors-adapted/selectors.c | 1 + 1 file changed, 1 insertion(+) diff --git a/ext/dom/lexbor/lexbor/selectors-adapted/selectors.c b/ext/dom/lexbor/lexbor/selectors-adapted/selectors.c index 8bd996a3910fe..7c8dd588aa480 100644 --- a/ext/dom/lexbor/lexbor/selectors-adapted/selectors.c +++ b/ext/dom/lexbor/lexbor/selectors-adapted/selectors.c @@ -6,6 +6,7 @@ * Based on Lexbor 2.4.0 (upstream commit e9d35f6384de7bd8c1b79e7111bc3a44f8822967) */ +#include #include #include #include From 56237da4d16acc31559a08b831c4fabacbb18a8f Mon Sep 17 00:00:00 2001 From: Peter Kokot Date: Thu, 22 Aug 2024 17:15:00 +0200 Subject: [PATCH 2/5] Autotools: Bump minimum libxml2 version to 2.9.4 --- UPGRADING | 4 ++++ UPGRADING.INTERNALS | 2 +- build/php.m4 | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/UPGRADING b/UPGRADING index 48740ce43418e..012cd89d60676 100644 --- a/UPGRADING +++ b/UPGRADING @@ -871,6 +871,10 @@ 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 and PHP_SETUP_LIBXML Autoconf macro now require 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 fe4fd258531a5..66666171fadbb 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). - TSRM/tsrm.m4 file and its TSRM_CHECK_PTHREADS M4 macro have been removed. diff --git a/build/php.m4 b/build/php.m4 index da316944f3e2a..47816ca5fcb0c 100644 --- a/build/php.m4 +++ b/build/php.m4 @@ -1934,7 +1934,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 From 55ca034a8ae9d9e798415a9b73a577700d026ce1 Mon Sep 17 00:00:00 2001 From: Peter Kokot Date: Thu, 22 Aug 2024 17:18:56 +0200 Subject: [PATCH 3/5] Remove redundant include file --- ext/dom/lexbor/lexbor/selectors-adapted/selectors.c | 1 - 1 file changed, 1 deletion(-) diff --git a/ext/dom/lexbor/lexbor/selectors-adapted/selectors.c b/ext/dom/lexbor/lexbor/selectors-adapted/selectors.c index 7c8dd588aa480..8bd996a3910fe 100644 --- a/ext/dom/lexbor/lexbor/selectors-adapted/selectors.c +++ b/ext/dom/lexbor/lexbor/selectors-adapted/selectors.c @@ -6,7 +6,6 @@ * Based on Lexbor 2.4.0 (upstream commit e9d35f6384de7bd8c1b79e7111bc3a44f8822967) */ -#include #include #include #include From ca8bd233c5d6463458a2667fff7466eb5aa684a7 Mon Sep 17 00:00:00 2001 From: Peter Kokot Date: Thu, 22 Aug 2024 17:56:11 +0200 Subject: [PATCH 4/5] [skip ci] Simplify UPGRADING note --- UPGRADING | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/UPGRADING b/UPGRADING index 012cd89d60676..cf74fc89b789c 100644 --- a/UPGRADING +++ b/UPGRADING @@ -872,8 +872,7 @@ PHP 8.4 UPGRADE NOTES INTL_IDNA_VARIANT_UTS46. - LibXML: - . The libxml extension and PHP_SETUP_LIBXML Autoconf macro now require at - least libxml2 2.9.4. + . The libxml extension now requires at least libxml2 2.9.4. - MBString: . Unicode data tables have been updated to Unicode 15.1. From ffd8ab5550e12f3f8ca070de57d0356f744e0cb9 Mon Sep 17 00:00:00 2001 From: "Christoph M. Becker" Date: Thu, 22 Aug 2024 19:33:36 +0200 Subject: [PATCH 5/5] Check libxml2 version on Windows --- ext/libxml/config.w32 | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) 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"