Commit 5c4bff65781 for php.net

commit 5c4bff65781a6dfc12b7a46860becda7470244f3
Author: Gina Peter Banyard <girgias@php.net>
Date:   Sun Jul 19 19:17:50 2026 +0100

    main: convert sys_temp_dir global to zend_string* (#22812)

    This removes a strlen() call when we already know the length of the string

diff --git a/main/main.c b/main/main.c
index 4348ec41092..e29770a909e 100644
--- a/main/main.c
+++ b/main/main.c
@@ -839,7 +839,7 @@ PHP_INI_BEGIN()
 	STD_PHP_INI_ENTRY("error_log",				NULL,			PHP_INI_ALL,		OnUpdateErrorLog,				error_log,				php_core_globals,	core_globals)
 	STD_PHP_INI_ENTRY("error_log_mode",			"0644",			PHP_INI_ALL,		OnUpdateLong,					error_log_mode,			php_core_globals,	core_globals)
 	STD_PHP_INI_ENTRY("extension_dir",			PHP_EXTENSION_DIR,		PHP_INI_SYSTEM,		OnUpdateStringUnempty,	extension_dir,			php_core_globals,	core_globals)
-	STD_PHP_INI_ENTRY("sys_temp_dir",			NULL,		PHP_INI_SYSTEM,		OnUpdateStringUnempty,	sys_temp_dir,			php_core_globals,	core_globals)
+	STD_PHP_INI_ENTRY("sys_temp_dir",			NULL,		PHP_INI_SYSTEM,		OnUpdateStrNotEmpty,	sys_temp_dir,			php_core_globals,	core_globals)
 	STD_PHP_INI_ENTRY("include_path",			PHP_INCLUDE_PATH,		PHP_INI_ALL,		OnUpdateStringUnempty,	include_path,			php_core_globals,	core_globals)
 	PHP_INI_ENTRY("max_execution_time",			"30",		PHP_INI_ALL,			OnUpdateTimeout)
 	STD_PHP_INI_ENTRY("open_basedir",			NULL,		PHP_INI_ALL,		OnUpdateBaseDir,			open_basedir,			php_core_globals,	core_globals)
diff --git a/main/php_globals.h b/main/php_globals.h
index 8a032e9edb1..0bab9fc95c1 100644
--- a/main/php_globals.h
+++ b/main/php_globals.h
@@ -83,7 +83,7 @@ struct _php_core_globals {
 	bool open_basedir_modified;
 	char *extension_dir;
 	char *php_binary;
-	char *sys_temp_dir;
+	zend_string *sys_temp_dir;

 	char *upload_tmp_dir;
 	zend_long upload_max_filesize;
diff --git a/main/php_open_temporary_file.c b/main/php_open_temporary_file.c
index ffc1c754d9e..7a33fa3ce19 100644
--- a/main/php_open_temporary_file.c
+++ b/main/php_open_temporary_file.c
@@ -240,14 +240,14 @@ PHPAPI const char* php_get_temporary_directory(void)

 	/* Is there a temporary directory "sys_temp_dir" in .ini defined? */
 	{
-		char *sys_temp_dir = PG(sys_temp_dir);
+		const zend_string *sys_temp_dir = PG(sys_temp_dir);
 		if (sys_temp_dir) {
-			size_t len = strlen(sys_temp_dir);
-			if (len >= 2 && sys_temp_dir[len - 1] == DEFAULT_SLASH) {
-				PG(php_sys_temp_dir) = estrndup(sys_temp_dir, len - 1);
+			size_t len = ZSTR_LEN(sys_temp_dir);
+			if (len >= 2 && ZSTR_VAL(sys_temp_dir)[len - 1] == DEFAULT_SLASH) {
+				PG(php_sys_temp_dir) = estrndup(ZSTR_VAL(sys_temp_dir), len - 1);
 				return PG(php_sys_temp_dir);
-			} else if (len >= 1 && sys_temp_dir[len - 1] != DEFAULT_SLASH) {
-				PG(php_sys_temp_dir) = estrndup(sys_temp_dir, len);
+			} else if (len >= 1 && ZSTR_VAL(sys_temp_dir)[len - 1] != DEFAULT_SLASH) {
+				PG(php_sys_temp_dir) = estrndup(ZSTR_VAL(sys_temp_dir), len);
 				return PG(php_sys_temp_dir);
 			}
 		}