[packages/php/PHP_5_2] libxml2 and readdir fixes; more needed
arekm
arekm at pld-linux.org
Mon Jul 14 15:10:30 CEST 2025
commit b20b8b31b3d6c318d1683b1d86bef560daa3dd1b
Author: Arkadiusz Miśkiewicz <arekm at maven.pl>
Date: Mon Jul 14 15:10:22 2025 +0200
libxml2 and readdir fixes; more needed
libxml2.patch | 90 ++++++++++++++++++++++++++++
php-php_dl.patch | 4 +-
php.spec | 6 +-
readdir.patch | 178 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
4 files changed, 275 insertions(+), 3 deletions(-)
---
diff --git a/php.spec b/php.spec
index f84ea54..fe593a4 100644
--- a/php.spec
+++ b/php.spec
@@ -228,6 +228,8 @@ Patch78: php-bug-68486.patch
Patch79: libevent-2.1.patch
Patch80: mysqli-err.patch
Patch81: openssl.patch
+Patch82: libxml2.patch
+Patch83: readdir.patch
# CENTALT patches
# Backport from 5.3.6
Patch311: php-5.3.6-bug-47435.patch
@@ -1990,6 +1992,8 @@ done
%patch -P79 -p1
%patch -P80 -p1
%patch -P81 -p1
+%patch -P82 -p1
+%patch -P83 -p1
# Bugfix backport from 5.3.6
%patch -P311 -p1 -b .bug-47435
@@ -1998,7 +2002,7 @@ done
#accert %%patch -P333 -p1 -b .bug-54924
#soap %%patch -P355 -p1 -b .bug-55323
# causes regression -> magic_quotes_gpc setting cannot be changed
-#%%%patch -P402 -p1 -b .bug-323016
+#%%patch -P402 -p1 -b .bug-323016
# cleanup backups after patching
find '(' -name '*~' -o -name '*.orig' ')' -print0 | xargs -0 -r -l512 rm -f
diff --git a/libxml2.patch b/libxml2.patch
new file mode 100644
index 0000000..7d52164
--- /dev/null
+++ b/libxml2.patch
@@ -0,0 +1,90 @@
+From 0a39890c967aa57225bb6bdf4821aff7a3a3c082 Mon Sep 17 00:00:00 2001
+From: Niels Dossche <7771979+nielsdos at users.noreply.github.com>
+Date: Fri, 1 Dec 2023 18:03:35 +0100
+Subject: [PATCH] Fix libxml2 2.12 build due to API breaks
+
+See https://github.com/php/php-src/actions/runs/7062192818/job/19225478601
+---
+ ext/libxml/libxml.c | 14 ++++++++++----
+ ext/soap/php_sdl.c | 2 +-
+ 2 files changed, 11 insertions(+), 5 deletions(-)
+
+diff --git a/ext/libxml/libxml.c b/ext/libxml/libxml.c
+index 22eb1901b8909..1de693892b7aa 100644
+--- a/ext/libxml/libxml.c
++++ b/ext/libxml/libxml.c
+@@ -472,7 +472,11 @@ static void _php_libxml_free_error(void *ptr)
+ return 1;
+ }
+
+-static void _php_list_set_error_structure(xmlErrorPtr error, const char *msg)
++#if LIBXML_VERSION >= 21200
++static void _php_list_set_error_structure(const xmlError *error, const char *msg)
++#else
++static void _php_list_set_error_structure(xmlError *error, const char *msg)
++#endif
+ {
+ xmlError error_copy;
+ int ret;
+@@ -725,7 +729,11 @@ PHP_LIBXML_API void php_libxml_ctx_warning(void *ctx, const char *msg, ...)
+ va_end(args);
+ }
+
++#if LIBXML_VERSION >= 21200
++PHP_LIBXML_API void php_libxml_structured_error_handler(void *userData, const xmlError *error)
++#else
+ PHP_LIBXML_API void php_libxml_structured_error_handler(void *userData, xmlErrorPtr error)
++#endif
+ {
+ _php_list_set_error_structure(error, NULL);
+
+@@ -957,9 +965,7 @@ PHP_FUNCTION(libxml_use_internal_errors)
+ Retrieve last error from libxml */
+ static PHP_FUNCTION(libxml_get_last_error)
+ {
+- xmlErrorPtr error;
+-
+- error = xmlGetLastError();
++ const xmlError *error = xmlGetLastError();
+
+ if (error) {
+ object_init_ex(return_value, libxmlerror_class_entry);
+--- php-5.2.17/ext/soap/php_sdl.c~ 2025-07-14 12:36:58.000000000 +0200
++++ php-5.2.17/ext/soap/php_sdl.c 2025-07-14 12:38:18.655352040 +0200
+@@ -300,7 +300,7 @@ static void load_wsdl_ex(zval *this_ptr,
+ sdl_restore_uri_credentials(ctx TSRMLS_CC);
+
+ if (!wsdl) {
+- xmlErrorPtr xmlErrorPtr = xmlGetLastError();
++ const xmlErrorPtr xmlErrorPtr = xmlGetLastError();
+ if (xmlErrorPtr) {
+ soap_error2(E_ERROR, "Parsing WSDL: Couldn't load from '%s' : %s", struri, xmlErrorPtr->message);
+ } else {
+--- php-5.2.17/ext/dom/dom_iterators.c~ 2010-01-03 10:23:27.000000000 +0100
++++ php-5.2.17/ext/dom/dom_iterators.c 2025-07-14 12:39:18.039049634 +0200
+@@ -42,7 +42,7 @@ struct _notationIterator {
+ xmlNotation *notation;
+ };
+
+-static void itemHashScanner (void *payload, void *data, xmlChar *name) {
++static void itemHashScanner (void *payload, void *data, const xmlChar *name) {
+ nodeIterator *priv = (nodeIterator *)data;
+
+ if(priv->cur < priv->index) {
+diff --git a/ext/libxml/libxml.c b/ext/libxml/libxml.c
+index 6cdfbd397f7..dc5e7790952 100644
+--- a/ext/libxml/libxml.c
++++ b/ext/libxml/libxml.c
+@@ -430,8 +430,10 @@ php_libxml_input_buffer_create_filename(const char *URI, xmlCharEncoding enc)
+ static xmlOutputBufferPtr
+ php_libxml_output_buffer_create_filename(const char *URI,
+ xmlCharEncodingHandlerPtr encoder,
+- int compression ATTRIBUTE_UNUSED)
++ int compression)
+ {
++
++
+ xmlOutputBufferPtr ret;
+ xmlURIPtr puri;
+ void *context = NULL;
+
diff --git a/php-php_dl.patch b/php-php_dl.patch
index 998961f..f70d16e 100644
--- a/php-php_dl.patch
+++ b/php-php_dl.patch
@@ -28,7 +28,7 @@ this allows to load permanent modules with full path (eases make test code)
- RETURN_FALSE;
- }
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Temporary module name should contain only filename");
-+ return FAILURE;
++ RETURN_FALSE;
}
+ libpath = estrdup(filename);
+ } else if (extension_dir && extension_dir[0]) {
@@ -43,7 +43,7 @@ this allows to load permanent modules with full path (eases make test code)
}
} else {
- libpath = estrndup(Z_STRVAL_P(file), Z_STRLEN_P(file));
-+ return FAILURE; /* Not full path given or extension_dir is not set */
++ RETURN_FALSE; /* Not full path given or extension_dir is not set */
}
/* load dynamic symbol */
diff --git a/readdir.patch b/readdir.patch
new file mode 100644
index 0000000..a2aaa8e
--- /dev/null
+++ b/readdir.patch
@@ -0,0 +1,178 @@
+diff -ur php-5.2.17.org/ext/session/mod_files.c php-5.2.17/ext/session/mod_files.c
+--- php-5.2.17.org/ext/session/mod_files.c 2025-07-14 14:22:45.636981032 +0200
++++ php-5.2.17/ext/session/mod_files.c 2025-07-14 14:24:07.700813103 +0200
+@@ -210,7 +210,7 @@
+ {
+ DIR *dir;
+ char dentry[sizeof(struct dirent) + MAXPATHLEN];
+- struct dirent *entry = (struct dirent *) &dentry;
++ struct dirent *entry;
+ struct stat sbuf;
+ char buf[MAXPATHLEN];
+ time_t now;
+@@ -230,7 +230,7 @@
+ memcpy(buf, dirname, dirname_len);
+ buf[dirname_len] = PHP_DIR_SEPARATOR;
+
+- while (php_readdir_r(dir, (struct dirent *) dentry, &entry) == 0 && entry) {
++ while ((entry = readdir(dir))) {
+ /* does the file start with our prefix? */
+ if (!strncmp(entry->d_name, FILE_PREFIX, sizeof(FILE_PREFIX) - 1)) {
+ size_t entry_len = strlen(entry->d_name);
+Tylko w php-5.2.17/ext/session: mod_files.c~
+diff -ur php-5.2.17.org/ext/session/mod_files.c.orig php-5.2.17/ext/session/mod_files.c.orig
+--- php-5.2.17.org/ext/session/mod_files.c.orig 2010-01-03 10:23:27.000000000 +0100
++++ php-5.2.17/ext/session/mod_files.c.orig 2025-07-14 14:23:54.200731143 +0200
+@@ -210,7 +210,7 @@
+ {
+ DIR *dir;
+ char dentry[sizeof(struct dirent) + MAXPATHLEN];
+- struct dirent *entry = (struct dirent *) &dentry;
++ struct dirent *entry;
+ struct stat sbuf;
+ char buf[MAXPATHLEN];
+ time_t now;
+@@ -231,7 +231,7 @@
+ memcpy(buf, dirname, dirname_len);
+ buf[dirname_len] = PHP_DIR_SEPARATOR;
+
+- while (php_readdir_r(dir, (struct dirent *) dentry, &entry) == 0 && entry) {
++ while ((entry = readdir(dir))) {
+ /* does the file start with our prefix? */
+ if (!strncmp(entry->d_name, FILE_PREFIX, sizeof(FILE_PREFIX) - 1)) {
+ size_t entry_len = strlen(entry->d_name);
+Tylko w php-5.2.17/ext/session: mod_files.c.orig~
+diff -ur php-5.2.17.org/main/php_reentrancy.h php-5.2.17/main/php_reentrancy.h
+--- php-5.2.17.org/main/php_reentrancy.h 2010-01-03 10:23:27.000000000 +0100
++++ php-5.2.17/main/php_reentrancy.h 2025-07-14 14:25:00.217798607 +0200
+@@ -51,13 +51,6 @@
+
+ BEGIN_EXTERN_C()
+
+-#if defined(HAVE_POSIX_READDIR_R)
+-#define php_readdir_r readdir_r
+-#else
+-PHPAPI int php_readdir_r(DIR *dirp, struct dirent *entry,
+- struct dirent **result);
+-#endif
+-
+ #if !defined(HAVE_LOCALTIME_R) && defined(HAVE_LOCALTIME)
+ #define PHP_NEED_REENTRANCY 1
+ PHPAPI struct tm *php_localtime_r(const time_t *const timep, struct tm *p_tm);
+Tylko w php-5.2.17/main: php_reentrancy.h~
+diff -ur php-5.2.17.org/main/php_scandir.c php-5.2.17/main/php_scandir.c
+--- php-5.2.17.org/main/php_scandir.c 2010-01-03 10:23:27.000000000 +0100
++++ php-5.2.17/main/php_scandir.c 2025-07-14 14:26:11.348230448 +0200
+@@ -64,7 +64,7 @@
+ int vector_size = 0;
+ int nfiles = 0;
+ char entry[sizeof(struct dirent)+MAXPATHLEN];
+- struct dirent *dp = (struct dirent *)&entry;
++ struct dirent *dp;
+
+ if (namelist == NULL) {
+ return -1;
+@@ -74,7 +74,7 @@
+ return -1;
+ }
+
+- while (!php_readdir_r(dirp, (struct dirent *)entry, &dp) && dp) {
++ while ((dp = readdir(dirp))) {
+ int dsize = 0;
+ struct dirent *newdp = NULL;
+
+Tylko w php-5.2.17/main: php_scandir.c~
+diff -ur php-5.2.17.org/main/reentrancy.c php-5.2.17/main/reentrancy.c
+--- php-5.2.17.org/main/reentrancy.c 2025-07-14 14:22:45.206978415 +0200
++++ php-5.2.17/main/reentrancy.c 2025-07-14 14:26:26.958325219 +0200
+@@ -123,54 +123,6 @@
+
+ #endif /* BEOS */
+
+-#if !defined(HAVE_POSIX_READDIR_R)
+-
+-PHPAPI int php_readdir_r(DIR *dirp, struct dirent *entry,
+- struct dirent **result)
+-{
+-#if defined(HAVE_OLD_READDIR_R)
+- int ret = 0;
+-
+- /* We cannot rely on the return value of readdir_r
+- as it differs between various platforms
+- (HPUX returns 0 on success whereas Solaris returns non-zero)
+- */
+- entry->d_name[0] = '\0';
+- readdir_r(dirp, entry);
+-
+- if (entry->d_name[0] == '\0') {
+- *result = NULL;
+- ret = errno;
+- } else {
+- *result = entry;
+- }
+- return ret;
+-#else
+- struct dirent *ptr;
+- int ret = 0;
+-
+- local_lock(READDIR_R);
+-
+- errno = 0;
+-
+- ptr = readdir(dirp);
+-
+- if (!ptr && errno != 0)
+- ret = errno;
+-
+- if (ptr)
+- memcpy(entry, ptr, sizeof(*ptr));
+-
+- *result = ptr;
+-
+- local_unlock(READDIR_R);
+-
+- return ret;
+-#endif
+-}
+-
+-#endif
+-
+ #if !defined(HAVE_LOCALTIME_R) && defined(HAVE_LOCALTIME)
+
+ PHPAPI struct tm *php_localtime_r(const time_t *const timep, struct tm *p_tm)
+Tylko w php-5.2.17/main: reentrancy.c~
+diff -ur php-5.2.17.org/main/streams/plain_wrapper.c php-5.2.17/main/streams/plain_wrapper.c
+--- php-5.2.17.org/main/streams/plain_wrapper.c 2010-01-03 10:23:27.000000000 +0100
++++ php-5.2.17/main/streams/plain_wrapper.c 2025-07-14 14:26:52.965149775 +0200
+@@ -808,14 +808,15 @@
+ DIR *dir = (DIR*)stream->abstract;
+ /* avoid libc5 readdir problems */
+ char entry[sizeof(struct dirent)+MAXPATHLEN];
+- struct dirent *result = (struct dirent *)&entry;
++ struct dirent *result;
+ php_stream_dirent *ent = (php_stream_dirent*)buf;
+
+ /* avoid problems if someone mis-uses the stream */
+ if (count != sizeof(php_stream_dirent))
+ return 0;
+
+- if (php_readdir_r(dir, (struct dirent *)entry, &result) == 0 && result) {
++ result = readdir(dir);
++ if (result) {
+ PHP_STRLCPY(ent->d_name, result->d_name, sizeof(ent->d_name), strlen(result->d_name));
+ return sizeof(php_stream_dirent);
+ }
+Tylko w php-5.2.17/main/streams: plain_wrapper.c~
+diff -ur php-5.2.17.org/win32/readdir.h php-5.2.17/win32/readdir.h
+--- php-5.2.17.org/win32/readdir.h 2006-12-01 21:17:50.000000000 +0100
++++ php-5.2.17/win32/readdir.h 2025-07-14 14:23:23.500544759 +0200
+@@ -17,8 +17,6 @@
+ #include <sys/types.h>
+ #include <direct.h>
+
+-#define php_readdir_r readdir_r
+-
+ /* struct dirent - same as Unix */
+
+ struct dirent {
+Tylko w php-5.2.17/win32: readdir.h~
================================================================
---- gitweb:
http://git.pld-linux.org/gitweb.cgi/packages/php.git/commitdiff/b20b8b31b3d6c318d1683b1d86bef560daa3dd1b
More information about the pld-cvs-commit
mailing list