From dae6e9ec703ae6a33c9ba8ff8f9170b50e2580ee Mon Sep 17 00:00:00 2001 From: Jorg Sowa Date: Sun, 22 Nov 2026 21:45:25 +0100 Subject: [PATCH 1/3] main/flock_compat: remove dead no-lock fallback struct flock is POSIX and every supported non-Windows platform has it, so drop the HAVE_STRUCT_FLOCK check and the stub that silently skipped locking. --- UPGRADING.INTERNALS | 1 + configure.ac | 1 - main/flock_compat.c | 12 ++---------- main/flock_compat.h | 10 ++++------ 4 files changed, 7 insertions(+), 17 deletions(-) diff --git a/UPGRADING.INTERNALS b/UPGRADING.INTERNALS index a2f9bc7f01c9..eae5457f7f23 100644 --- a/UPGRADING.INTERNALS +++ b/UPGRADING.INTERNALS @@ -52,6 +52,7 @@ PHP 8.7 INTERNALS UPGRADE NOTES dependencies from PHP. - Removed: + . The HAVE_STRUCT_FLOCK configure macro was removed. . The ZEND_LOG_XOR() macro was removed. . The ZEND_TRUTH() macro was removed. . Removed zend_execute_scripts(). Manually call zend_execute_script() in a diff --git a/configure.ac b/configure.ac index 40675011a2c0..3779b90f79ce 100644 --- a/configure.ac +++ b/configure.ac @@ -456,7 +456,6 @@ AC_STRUCT_TIMEZONE PHP_MISSING_TIME_R_DECL -AC_CHECK_TYPES([struct flock],,,[#include ]) AC_CHECK_TYPES([socklen_t], [], [], [ #ifdef HAVE_SYS_TYPES_H # include diff --git a/main/flock_compat.c b/main/flock_compat.c index 410f45afdb66..7b376d10e06e 100644 --- a/main/flock_compat.c +++ b/main/flock_compat.c @@ -24,7 +24,7 @@ PHPAPI int flock(int fd, int operation) #endif /* !defined(HAVE_FLOCK) */ PHPAPI int php_flock(int fd, int operation) -#ifdef HAVE_STRUCT_FLOCK /* {{{ */ +#ifndef PHP_WIN32 { struct flock flck; int ret; @@ -53,8 +53,7 @@ PHPAPI int php_flock(int fd, int operation) return ret; } -/* }}} */ -#elif defined(PHP_WIN32) /* {{{ */ +#else /* * Program: Unix compatibility routines * @@ -138,11 +137,4 @@ PHPAPI int php_flock(int fd, int operation) return -1; } -/* }}} */ -#else -#warning no proper flock support for your site -{ - errno = 0; - return 0; -} #endif diff --git a/main/flock_compat.h b/main/flock_compat.h index cfb6d82ba085..082c10d82487 100644 --- a/main/flock_compat.h +++ b/main/flock_compat.h @@ -15,15 +15,13 @@ #ifndef FLOCK_COMPAT_H #define FLOCK_COMPAT_H -#ifdef HAVE_STRUCT_FLOCK -#include -#include -#include -#endif - #ifdef PHP_WIN32 #include #include "config.w32.h" +#else +#include +#include +#include #endif /* php_flock internally uses fcntl whether or not flock is available From 6471227862895cb23c72badd98111e69879b1204 Mon Sep 17 00:00:00 2001 From: Jorg Sowa Date: Sun, 22 Nov 2026 21:45:25 +0100 Subject: [PATCH 2/3] opcache: use flock_compat.h instead of no-op file cache lock On non-Windows platforms without flock(), flock_compat.h provides one backed by fcntl, so the stub that skipped locking is not needed. --- ext/opcache/zend_file_cache.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/ext/opcache/zend_file_cache.c b/ext/opcache/zend_file_cache.c index 40be83d1ec62..d36e1ac61de9 100644 --- a/ext/opcache/zend_file_cache.c +++ b/ext/opcache/zend_file_cache.c @@ -93,16 +93,9 @@ static int zend_file_cache_flock(int fd, int op) } return -1; } -#elif defined(HAVE_FLOCK) -# define zend_file_cache_flock flock #else -# define LOCK_SH 0 -# define LOCK_EX 1 -# define LOCK_UN 2 -static int zend_file_cache_flock(int fd, int type) -{ - return 0; -} +# include "main/flock_compat.h" +# define zend_file_cache_flock flock #endif #ifndef O_BINARY From 61365c15e08eaa654a4c575256f05192bf62ae77 Mon Sep 17 00:00:00 2001 From: Jorg Sowa Date: Tue, 24 Nov 2026 11:32:34 +0100 Subject: [PATCH 3/3] opcache: remove file cache entry when LOCK_EX fails Otherwise the freshly created empty .bin blocks later stores until a load removes it. --- ext/opcache/zend_file_cache.c | 1 + 1 file changed, 1 insertion(+) diff --git a/ext/opcache/zend_file_cache.c b/ext/opcache/zend_file_cache.c index d36e1ac61de9..fed78e686d0e 100644 --- a/ext/opcache/zend_file_cache.c +++ b/ext/opcache/zend_file_cache.c @@ -1150,6 +1150,7 @@ int zend_file_cache_script_store(zend_persistent_script *script, bool in_shm) if (zend_file_cache_flock(fd, LOCK_EX) != 0) { close(fd); + zend_file_cache_unlink(filename); efree(filename); return FAILURE; }