[php-src] master: zend: Remove `zend_execute_scripts()` (#23864)

From: Date: Wed, 23 Sep 2026 17:55:04 +0000
Subject: [php-src] master: zend: Remove `zend_execute_scripts()` (#23864)
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-141481@lists.php.net to get a copy of this message
Author: Tim Düsterhus (TimWolla) Committer: GitHub (web-flow) Pusher: TimWolla Date: 2026-09-23T19:55:01+02:00 Commit: https://github.com/php/php-src/commit/32e268fd55cadd9922b44f01dab75671176ba2a1 Raw diff: https://github.com/php/php-src/commit/32e268fd55cadd9922b44f01dab75671176ba2a1.diff zend: Remove zend_execute_scripts() (#23864) This function is unsafe, because it reused the retval for each execution, without clearing it in-between each script, leading to memory leaks. Instead of fixing it, we just remove it: Writing a loop yourself is not much more complicated than using this variadic function and provides more flexibility. Changed paths: M UPGRADING.INTERNALS M Zend/zend.c M Zend/zend_compile.h M ext/readline/readline_cli.c M main/main.c M sapi/apache2handler/sapi_apache2.c Diff: diff --git a/UPGRADING.INTERNALS b/UPGRADING.INTERNALS index 41432be1e429..b2aa21986efb 100644 --- a/UPGRADING.INTERNALS +++ b/UPGRADING.INTERNALS @@ -14,6 +14,9 @@ PHP 8.7 INTERNALS UPGRADE NOTES 1. Internal API changes ======================== +- Removed zend_execute_scripts(). Manually call zend_execute_script() in a loop + instead. + ======================== 2. Build system changes ======================== diff --git a/Zend/zend.c b/Zend/zend.c index 3cfc0ffd2512..3b16dc9c315b 100644 --- a/Zend/zend.c +++ b/Zend/zend.c @@ -1996,30 +1996,6 @@ ZEND_API zend_result zend_execute_script(int type, zval *retval, zend_file_handl return ret; } -ZEND_API zend_result zend_execute_scripts(int type, zval *retval, int file_count, ...) /* {{{ */ -{ - va_list files; - int i; - zend_file_handle *file_handle; - zend_result ret = SUCCESS; - - va_start(files, file_count); - for (i = 0; i < file_count; i++) { - file_handle = va_arg(files, zend_file_handle *); - if (!file_handle) { - continue; - } - if (ret == FAILURE) { - continue; - } - ret = zend_execute_script(type, retval, file_handle); - } - va_end(files); - - return ret; -} -/* }}} */ - #define COMPILED_STRING_DESCRIPTION_FORMAT "%s(%d) : %s" ZEND_API char *zend_make_compiled_string_description(const char *name) /* {{{ */ diff --git a/Zend/zend_compile.h b/Zend/zend_compile.h index 34a91183b2a9..6502770a2662 100644 --- a/Zend/zend_compile.h +++ b/Zend/zend_compile.h @@ -962,7 +962,6 @@ ZEND_API zend_op_array *compile_filename(int type, zend_string *filename); ZEND_API zend_op_array *zend_compile_ast(zend_ast *ast, int type, zend_string *filename); ZEND_API zend_ast *zend_compile_string_to_ast( zend_string *code, struct _zend_arena **ast_arena, zend_string *filename); -ZEND_API zend_result zend_execute_scripts(int type, zval *retval, int file_count, ...); ZEND_API zend_result zend_execute_script(int type, zval *retval, zend_file_handle *file_handle); ZEND_API zend_result open_file_for_scanning(zend_file_handle *file_handle); ZEND_API void init_op_array(zend_op_array *op_array, zend_function_type type, int initial_ops_size); diff --git a/ext/readline/readline_cli.c b/ext/readline/readline_cli.c index 1fe7c9c6b4df..973aea106112 100644 --- a/ext/readline/readline_cli.c +++ b/ext/readline/readline_cli.c @@ -607,7 +607,7 @@ static int readline_shell_run(void) /* {{{ */ zend_file_handle prepend_file; zend_stream_init_filename(&prepend_file, PG(auto_prepend_file)); - zend_execute_scripts(ZEND_REQUIRE, NULL, 1, &prepend_file); + zend_execute_script(ZEND_REQUIRE, NULL, &prepend_file); zend_destroy_file_handle(&prepend_file); } diff --git a/main/main.c b/main/main.c index 0539220de362..7a8d440c0d75 100644 --- a/main/main.c +++ b/main/main.c @@ -2553,7 +2553,7 @@ PHPAPI bool php_execute_script_ex(zend_file_handle *primary_file, zval *retval) } /* Only lookup the real file path and add it to the included_files list if already opened - * otherwise it will get opened and added to the included_files list in zend_execute_scripts + * otherwise it will get opened and added to the included_files list in zend_execute_script */ if (primary_file->filename && !zend_string_equals_literal(primary_file->filename, "Standard input code") && @@ -2654,7 +2654,7 @@ PHPAPI int php_execute_simple_script(zend_file_handle *primary_file, zval *ret) php_ignore_value(VCWD_GETCWD(old_cwd, OLD_CWD_SIZE-1)); VCWD_CHDIR_FILE(ZSTR_VAL(primary_file->filename)); } - zend_execute_scripts(ZEND_REQUIRE, ret, 1, primary_file); + zend_execute_script(ZEND_REQUIRE, ret, primary_file); } zend_end_try(); if (old_cwd[0] != '\0') { diff --git a/sapi/apache2handler/sapi_apache2.c b/sapi/apache2handler/sapi_apache2.c index 83b3f02fb743..72dff2b03a7b 100644 --- a/sapi/apache2handler/sapi_apache2.c +++ b/sapi/apache2handler/sapi_apache2.c @@ -714,7 +714,7 @@ zend_first_try { if (!parent_req) { php_execute_script(&zfd); } else { - zend_execute_scripts(ZEND_INCLUDE, NULL, 1, &zfd); + zend_execute_script(ZEND_INCLUDE, NULL, &zfd); } zend_destroy_file_handle(&zfd);

« previous php.cvs (#141481) next »