Commit 32e268fd55c for php.net

commit 32e268fd55cadd9922b44f01dab75671176ba2a1
Author: Tim Düsterhus <tim@tideways-gmbh.com>
Date:   Wed Sep 23 19:55:01 2026 +0200

    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.

diff --git a/UPGRADING.INTERNALS b/UPGRADING.INTERNALS
index 41432be1e42..b2aa21986ef 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 3cfc0ffd251..3b16dc9c315 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 34a91183b2a..6502770a266 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 1fe7c9c6b4d..973aea10611 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 0539220de36..7a8d440c0d7 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 83b3f02fb74..72dff2b03a7 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);