From 4b01cd1bf3fbd115106f8a9956094a9d5de76a00 Mon Sep 17 00:00:00 2001 From: Gina Peter Banyard Date: Tue, 10 Feb 2026 12:17:47 +0000 Subject: [PATCH 1/7] ext/session/mod_mm: implement VALIDATE_SID handler (#21178) Rather than "manually" doing it in the READ handler. At the same time, get rid of various inconsistent legacy handler macro definitions, thus mandating all modules to implement the create and validate SID handlers. The only handler that remains optional is the update timestamp one. --- UPGRADING.INTERNALS | 6 ++++++ ext/session/mod_mm.c | 42 +++++++++++++++++++-------------------- ext/session/php_session.h | 27 +++++-------------------- 3 files changed, 32 insertions(+), 43 deletions(-) diff --git a/UPGRADING.INTERNALS b/UPGRADING.INTERNALS index c79bd44556da..c4ad30b9bad5 100644 --- a/UPGRADING.INTERNALS +++ b/UPGRADING.INTERNALS @@ -100,6 +100,12 @@ PHP 8.6 INTERNALS UPGRADE NOTES `void **mod_data, zend_string *save_path, zend_string *session_name` rather than `void **mod_data, const char *save_path, const char *session_name` + . PS_FUNCS() now includes the PS_VALIDATE_SID_FUNC() + . PS_MOD() now requires that the PS_CREATE_SID_FUNC() and + PS_VALIDATE_SID_FUNC() functions are defined. + . PS_FUNCS_SID() and PS_MOD_SID() have been removed. + Either use PS_FUNCS()/PS_MOD() or PS_FUNCS_UPDATE_TIMESTAMP()/ + PS_MOD_UPDATE_TIMESTAMP() if timestamp support exists. - ext/standard: . _php_error_log() now has a formal return type of zend_result. diff --git a/ext/session/mod_mm.c b/ext/session/mod_mm.c index a2d9a5641e7f..d6312c5fa1f3 100644 --- a/ext/session/mod_mm.c +++ b/ext/session/mod_mm.c @@ -215,7 +215,7 @@ static zend_result ps_mm_key_exists(ps_mm *data, const zend_string *key) } const ps_module ps_mod_mm = { - PS_MOD_SID(mm) + PS_MOD(mm) }; #define PS_MM_DATA ps_mm *data = PS_GET_MOD_DATA() @@ -346,26 +346,7 @@ PS_READ_FUNC(mm) mm_lock(data->mm, MM_LOCK_RD); - /* If there is an ID and strict mode, verify existence */ - if (PS(use_strict_mode) - && ps_mm_key_exists(data, key) == FAILURE) { - /* key points to PS(id), but cannot change here. */ - if (key) { - efree(PS(id)); - PS(id) = NULL; - } - PS(id) = PS(mod)->s_create_sid((void **)&data); - if (!PS(id)) { - return FAILURE; - } - if (PS(use_cookies)) { - PS(send_cookie) = true; - } - php_session_reset_id(); - PS(session_status) = php_session_active; - } - - sd = ps_sd_lookup(data, PS(id), false); + sd = ps_sd_lookup(data, key, false); if (sd) { *val = zend_string_init(sd->data, sd->datalen, false); ret = SUCCESS; @@ -488,4 +469,23 @@ PS_CREATE_SID_FUNC(mm) return sid; } +/* + * Check session ID existence for use_strict_mode support. + * PARAMETERS: PS_VALIDATE_SID_ARGS in php_session.h + * RETURN VALUE: SUCCESS or FAILURE. + * + * Return SUCCESS for valid key(already existing session). + * Return FAILURE for invalid key(non-existing session). + * *mod_data, *key are guaranteed to have non-NULL values. + */ +PS_VALIDATE_SID_FUNC(mm) +{ + PS_MM_DATA; + + mm_lock(data->mm, MM_LOCK_RD); + zend_result ret = ps_mm_key_exists(data, key) + mm_unlock(data->mm); + return ret; +} + #endif diff --git a/ext/session/php_session.h b/ext/session/php_session.h index 8c857d29a5fc..836546867585 100644 --- a/ext/session/php_session.h +++ b/ext/session/php_session.h @@ -62,7 +62,7 @@ typedef struct ps_module_struct { #define PS_VALIDATE_SID_FUNC(x) zend_result ps_validate_sid_##x(PS_VALIDATE_SID_ARGS) #define PS_UPDATE_TIMESTAMP_FUNC(x) zend_result ps_update_timestamp_##x(PS_UPDATE_TIMESTAMP_ARGS) -/* Legacy save handler module definitions */ +/* Save handler module definitions without timestamp enabled */ #define PS_FUNCS(x) \ PS_OPEN_FUNC(x); \ PS_CLOSE_FUNC(x); \ @@ -70,32 +70,15 @@ typedef struct ps_module_struct { PS_WRITE_FUNC(x); \ PS_DESTROY_FUNC(x); \ PS_GC_FUNC(x); \ - PS_CREATE_SID_FUNC(x) + PS_CREATE_SID_FUNC(x) \ + PS_VALIDATE_SID_FUNC(x); #define PS_MOD(x) \ - #x, ps_open_##x, ps_close_##x, ps_read_##x, ps_write_##x, \ - ps_delete_##x, ps_gc_##x, php_session_create_id, \ - php_session_validate_sid, php_session_update_timestamp - -/* Legacy SID creation enabled save handler module definitions */ -#define PS_FUNCS_SID(x) \ - PS_OPEN_FUNC(x); \ - PS_CLOSE_FUNC(x); \ - PS_READ_FUNC(x); \ - PS_WRITE_FUNC(x); \ - PS_DESTROY_FUNC(x); \ - PS_GC_FUNC(x); \ - PS_CREATE_SID_FUNC(x); \ - PS_VALIDATE_SID_FUNC(x); \ - PS_UPDATE_TIMESTAMP_FUNC(x); - -#define PS_MOD_SID(x) \ #x, ps_open_##x, ps_close_##x, ps_read_##x, ps_write_##x, \ ps_delete_##x, ps_gc_##x, ps_create_sid_##x, \ - php_session_validate_sid, php_session_update_timestamp + ps_validate_sid_##x, NULL -/* Update timestamp enabled save handler module definitions - New save handlers should use this API */ +/* Save handlers with timestamp enabled, it is recommended to use this API */ #define PS_FUNCS_UPDATE_TIMESTAMP(x) \ PS_OPEN_FUNC(x); \ PS_CLOSE_FUNC(x); \ From 26559c5815a844b344d18a994277a7b567c6cb48 Mon Sep 17 00:00:00 2001 From: Arshid Date: Tue, 10 Feb 2026 17:50:42 +0530 Subject: [PATCH 2/7] ext/readline: Returning a boolean value using RETURN_BOOL (#21186) --- ext/readline/readline.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/ext/readline/readline.c b/ext/readline/readline.c index 61129194db20..dad6a726f1bf 100644 --- a/ext/readline/readline.c +++ b/ext/readline/readline.c @@ -495,10 +495,8 @@ PHP_FUNCTION(readline_completion_function) /* NOTE: The rl_attempted_completion_function variable (and others) are part of the readline library, not php */ rl_attempted_completion_function = php_readline_completion_cb; - if (rl_attempted_completion_function == NULL) { - RETURN_FALSE; - } - RETURN_TRUE; + + RETURN_BOOL(rl_attempted_completion_function != NULL); } /* }}} */ From c995a6cb4b7e26fb79daf79672ccad1079187e6c Mon Sep 17 00:00:00 2001 From: Arshid Date: Tue, 10 Feb 2026 17:56:18 +0530 Subject: [PATCH 3/7] ext/ftp: Returning a boolean value using RETURN_BOOL (#21187) --- ext/ftp/php_ftp.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/ext/ftp/php_ftp.c b/ext/ftp/php_ftp.c index ffba1192f058..245d95bf1260 100644 --- a/ext/ftp/php_ftp.c +++ b/ext/ftp/php_ftp.c @@ -678,11 +678,8 @@ PHP_FUNCTION(ftp_pasv) } GET_FTPBUF(ftp, z_ftp); - if (!ftp_pasv(ftp, pasv ? 1 : 0)) { - RETURN_FALSE; - } + RETURN_BOOL(ftp_pasv(ftp, pasv ? 1 : 0)); - RETURN_TRUE; } /* }}} */ From 4b723900c31f1c4b4c1d5f16d0b3d61f5b1df22f Mon Sep 17 00:00:00 2001 From: Peter Kokot Date: Tue, 10 Feb 2026 16:12:30 +0100 Subject: [PATCH 4/7] Update minimum required PHP version in Autotools build system (#20933) At the time of writing, PHP found on host system must be at least 8.0 for build/gen_stub.php and Zend/zend_vm_gen.php scripts to work. Minimum required version is updated to 8.1 to still support building PHP from source on any possible old systems, and enabling new features in build/gen_stub.php, such as readonly properties. --- configure.ac | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/configure.ac b/configure.ac index beeed7eb2111..a5d626553c44 100644 --- a/configure.ac +++ b/configure.ac @@ -160,8 +160,8 @@ PHP_RUNPATH_SWITCH dnl Checks for some support/generator progs. PHP_PROG_BISON([3.0.0]) PHP_PROG_RE2C([1.0.3], [--no-generation-date]) -dnl Find installed PHP. Minimum supported version for gen_stub.php is PHP 7.4. -PHP_PROG_PHP([7.4]) +dnl Find installed PHP. Minimum supported version for gen_stub.php is PHP 8.1. +PHP_PROG_PHP([8.1]) PHP_ARG_ENABLE([re2c-cgoto], [whether to enable computed goto extension with re2c], From ba996f7ae9793c8e2234bb7202c76646f3540755 Mon Sep 17 00:00:00 2001 From: Peter Kokot Date: Tue, 10 Feb 2026 16:21:31 +0100 Subject: [PATCH 5/7] Add note about updated PHP version [skip ci] --- UPGRADING.INTERNALS | 3 +++ 1 file changed, 3 insertions(+) diff --git a/UPGRADING.INTERNALS b/UPGRADING.INTERNALS index c4ad30b9bad5..5b3b04cd9baa 100644 --- a/UPGRADING.INTERNALS +++ b/UPGRADING.INTERNALS @@ -75,6 +75,9 @@ PHP 8.6 INTERNALS UPGRADE NOTES 2. Build system changes ======================== +- Abstract: + . Minimum required PHP version found on the host system for running scripts + like build/gen_stub.php during development has been updated from 7.4 to 8.1. . build/gen_stub.php may now generate a _decl.h file in addition to the _arginfo.h file, if the stub declares enums and is annotated with @generate-c-enums. For each enum the file will contain a C enum. Enum From 8032d6fa16e46488a302177dd60b0b1aa618d1a1 Mon Sep 17 00:00:00 2001 From: Peter Kokot Date: Tue, 10 Feb 2026 19:59:10 +0100 Subject: [PATCH 6/7] Autotools: Check struct stat.st_blocks with AC_CHECK_MEMBERS (#13562) The AC_STRUCT_ST_BLOCKS expects fileblocks object to be compiled with AC_LIBOBJ if stat.st_blocks is missing on the system. This can be simplified with the usual AC_CHECK_MEMBERS since PHP is using the stat.st_blocks (and stat.st_blksize) conditionally. These members are mostly present on all POSIX-based systems except on Windows these days. This also removes the obsolete HAVE_ST_BLOCKS symbol: https://git.savannah.gnu.org/cgit/autoconf.git/tree/lib/autoconf/types.m4?h=v2.72#n1055 Additionally, the st_blksize and st_blocks members are checked conditionally with HAVE_ preprocessor macros. Instead of filtering Windows specifically here, the preprocessor macros HAVE_STRUCT_STAT_ST_BLKSIZE and HAVE_STRUCT_STAT_ST_BLOCKS can be used. --- UPGRADING.INTERNALS | 4 ++++ configure.ac | 10 +++++----- ext/phar/func_interceptors.c | 4 +++- ext/phar/stream.c | 4 +++- ext/zip/zip_stream.c | 4 +++- main/streams/memory.c | 4 +++- 6 files changed, 21 insertions(+), 9 deletions(-) diff --git a/UPGRADING.INTERNALS b/UPGRADING.INTERNALS index 5b3b04cd9baa..83ef90e55587 100644 --- a/UPGRADING.INTERNALS +++ b/UPGRADING.INTERNALS @@ -84,6 +84,10 @@ PHP 8.6 INTERNALS UPGRADE NOTES values can be compared to the result of zend_enum_fetch_case_id(zend_object*). +- Unix build system changes: + . Symbol HAVE_ST_BLOCKS has been removed from php_config.h (use + HAVE_STRUCT_STAT_ST_BLOCKS). + ======================== 3. Module changes ======================== diff --git a/configure.ac b/configure.ac index a5d626553c44..d89d40ff85c2 100644 --- a/configure.ac +++ b/configure.ac @@ -504,11 +504,11 @@ AS_VAR_IF([php_cv_have_alignof], [yes], dnl Check for structure members. AC_CHECK_MEMBERS([struct tm.tm_gmtoff],,,[#include ]) -AC_CHECK_MEMBERS([struct stat.st_blksize, struct stat.st_rdev]) -dnl AC_STRUCT_ST_BLOCKS will screw QNX because fileblocks.o does not exist. -if test "$(uname -s 2>/dev/null)" != "QNX"; then - AC_STRUCT_ST_BLOCKS -fi +AC_CHECK_MEMBERS(m4_normalize([ + struct stat.st_blksize, + struct stat.st_blocks, + struct stat.st_rdev +])) dnl Checks for types. AC_TYPE_UID_T diff --git a/ext/phar/func_interceptors.c b/ext/phar/func_interceptors.c index f7e553a45ce8..5d5242e59009 100644 --- a/ext/phar/func_interceptors.c +++ b/ext/phar/func_interceptors.c @@ -631,8 +631,10 @@ static void phar_file_stat(const char *filename, size_t filename_length, int typ if (data) { sb.st_ino = data->inode; } -#ifndef PHP_WIN32 +#ifdef HAVE_STRUCT_STAT_ST_BLKSIZE sb.st_blksize = -1; +#endif +#ifdef HAVE_STRUCT_STAT_ST_BLOCKS sb.st_blocks = -1; #endif phar_fancy_stat(&sb, type, return_value); diff --git a/ext/phar/stream.c b/ext/phar/stream.c index 4bd1e85666b8..4bd53c98fced 100644 --- a/ext/phar/stream.c +++ b/ext/phar/stream.c @@ -526,8 +526,10 @@ void phar_dostat(phar_archive_data *phar, phar_entry_info *data, php_stream_stat if (!is_temp_dir) { ssb->sb.st_ino = data->inode; } -#ifndef PHP_WIN32 +#ifdef HAVE_STRUCT_STAT_ST_BLKSIZE ssb->sb.st_blksize = -1; +#endif +#ifdef HAVE_STRUCT_STAT_ST_BLOCKS ssb->sb.st_blocks = -1; #endif } diff --git a/ext/zip/zip_stream.c b/ext/zip/zip_stream.c index 50f097de3c87..3a5e56d071f5 100644 --- a/ext/zip/zip_stream.c +++ b/ext/zip/zip_stream.c @@ -177,8 +177,10 @@ static int php_zip_ops_stat(php_stream *stream, php_stream_statbuf *ssb) /* {{{ ssb->sb.st_ctime = sb.mtime; ssb->sb.st_nlink = 1; ssb->sb.st_rdev = -1; -#ifndef PHP_WIN32 +#ifdef HAVE_STRUCT_STAT_ST_BLKSIZE ssb->sb.st_blksize = -1; +#endif +#ifdef HAVE_STRUCT_STAT_ST_BLOCKS ssb->sb.st_blocks = -1; #endif ssb->sb.st_ino = -1; diff --git a/main/streams/memory.c b/main/streams/memory.c index 2f411ff8e8c9..66e0abe2c5fd 100644 --- a/main/streams/memory.c +++ b/main/streams/memory.c @@ -213,8 +213,10 @@ static int php_stream_memory_stat(php_stream *stream, php_stream_statbuf *ssb) / /* generate unique inode number for alias/filename, so no phars will conflict */ ssb->sb.st_ino = 0; -#ifndef PHP_WIN32 +#ifdef HAVE_STRUCT_STAT_ST_BLKSIZE ssb->sb.st_blksize = -1; +#endif +#ifdef HAVE_STRUCT_STAT_ST_BLOCKS ssb->sb.st_blocks = -1; #endif From defc0bec2e34765f48636636c5c60e7aa0134a50 Mon Sep 17 00:00:00 2001 From: Arshid Date: Wed, 11 Feb 2026 00:40:50 +0530 Subject: [PATCH 7/7] ext/dom: Returning a boolean value using RETURN_BOOL (#21188) --- ext/dom/xpath.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/ext/dom/xpath.c b/ext/dom/xpath.c index 21baa59ffed0..ce17c0810835 100644 --- a/ext/dom/xpath.c +++ b/ext/dom/xpath.c @@ -227,10 +227,7 @@ PHP_METHOD(DOMXPath, registerNamespace) RETURN_THROWS(); } - if (xmlXPathRegisterNs(ctxp, prefix, ns_uri) != 0) { - RETURN_FALSE; - } - RETURN_TRUE; + RETURN_BOOL(xmlXPathRegisterNs(ctxp, prefix, ns_uri) == 0); } /* }}} */