[php-src] master: Merge branch 'PHP-8.6'

From: Date: Tue, 03 Nov 2026 10:12:54 +0000
Subject: [php-src] master: Merge branch 'PHP-8.6'
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-143269@lists.php.net to get a copy of this message
Author: Arnaud Le Blanc (arnaud-lb) Date: 2026-11-03T11:12:36+01:00 Commit: https://github.com/php/php-src/commit/103482df34c8638cf5ca85d72b58bd34674eacfc Raw diff: https://github.com/php/php-src/commit/103482df34c8638cf5ca85d72b58bd34674eacfc.diff Merge branch 'PHP-8.6' * PHP-8.6: Fix windows embedded CLI argv overwriting (#24733) Changed paths: M sapi/cli/cli.h M sapi/cli/php_cli.c Diff: diff --git a/sapi/cli/cli.h b/sapi/cli/cli.h index 9502a6726fe4..abf41d510a59 100644 --- a/sapi/cli/cli.h +++ b/sapi/cli/cli.h @@ -55,6 +55,7 @@ typedef struct php_cli_server_context { } php_cli_server_context; /* this performs full cli-SAPI boot, loads modules, sets up TSRM and co. */ +/* On Windows, custom argv must use PHP's internal encoding (UTF-8 by default). */ extern PHP_CLI_API int do_php_cli(int argc, char *argv[]); #endif /* CLI_H */ diff --git a/sapi/cli/php_cli.c b/sapi/cli/php_cli.c index 55251f099bcb..fc62c0dd4b46 100644 --- a/sapi/cli/php_cli.c +++ b/sapi/cli/php_cli.c @@ -1334,12 +1334,16 @@ PHP_CLI_API int do_php_cli(int argc, char *argv[]) #if defined(PHP_WIN32) php_win32_cp_cli_setup(); orig_cp = (php_win32_cp_get_orig())->id; - /* Ignore the delivered argv and argc, read from W API. This place - might be too late though, but this is the earliest place ATW - we can access the internal charset information from PHP. */ - argv_wide = CommandLineToArgvW(GetCommandLineW(), &num_args); - PHP_WIN32_CP_W_TO_ANY_ARRAY(argv_wide, num_args, argv, argc) - using_wide_argv = 1; + /* Embedders supply their own arguments, we mustn't replace them with + * the ones by the host process command line. */ + if (argv_save == __argv) { + /* Ignore the delivered argv and argc, read from W API. This place + might be too late though, but this is the earliest place ATW + we can access the internal charset information from PHP. */ + argv_wide = CommandLineToArgvW(GetCommandLineW(), &num_args); + PHP_WIN32_CP_W_TO_ANY_ARRAY(argv_wide, num_args, argv, argc) + using_wide_argv = 1; + } SetConsoleCtrlHandler(php_cli_win32_ctrl_handler, TRUE); #endif

« previous php.cvs (#143269) next »