Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 93974c6

Browse files
committed
main: Change the register_argc_argv INI default to Off
This partly implements the deprecation of the `register_argc_argv` INI setting by updating the default value to ensure safe behavior when no INI file is loaded. The actual deprecation warning will follow separately. RFC: https://wiki.php.net/rfc/deprecations_php_8_5#deprecate_the_register_argc_argv_ini_directive
1 parent e844e68 commit 93974c6

File tree

5 files changed

+35
-23
lines changed

5 files changed

+35
-23
lines changed

‎main/main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -783,7 +783,7 @@ PHP_INI_BEGIN()
783783
STD_PHP_INI_BOOLEAN("report_zend_debug", "0", PHP_INI_ALL, OnUpdateBool, report_zend_debug, php_core_globals, core_globals)
784784
STD_PHP_INI_ENTRY("output_buffering", "0", PHP_INI_PERDIR|PHP_INI_SYSTEM, OnUpdateLong, output_buffering, php_core_globals, core_globals)
785785
STD_PHP_INI_ENTRY("output_handler", NULL, PHP_INI_PERDIR|PHP_INI_SYSTEM, OnUpdateString, output_handler, php_core_globals, core_globals)
786-
STD_PHP_INI_BOOLEAN("register_argc_argv", "1", PHP_INI_PERDIR|PHP_INI_SYSTEM, OnUpdateBool, register_argc_argv, php_core_globals, core_globals)
786+
STD_PHP_INI_BOOLEAN("register_argc_argv", "0", PHP_INI_PERDIR|PHP_INI_SYSTEM, OnUpdateBool, register_argc_argv, php_core_globals, core_globals)
787787
STD_PHP_INI_BOOLEAN("auto_globals_jit", "1", PHP_INI_PERDIR|PHP_INI_SYSTEM, OnUpdateBool, auto_globals_jit, php_core_globals, core_globals)
788788
STD_PHP_INI_BOOLEAN("short_open_tag", DEFAULT_SHORT_OPEN_TAG, PHP_INI_SYSTEM|PHP_INI_PERDIR, OnUpdateBool, short_tags, zend_compiler_globals, compiler_globals)
789789

‎php.ini-development

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -129,11 +129,6 @@
129129
; Development Value: 4096
130130
; Production Value: 4096
131131

132-
; register_argc_argv
133-
; Default Value: On
134-
; Development Value: Off
135-
; Production Value: Off
136-
137132
; request_order
138133
; Default Value: None
139134
; Development Value: "GP"
@@ -665,14 +660,12 @@ request_order = "GP"
665660
; that were passed when the script was invoked. These arrays are extremely
666661
; useful when running scripts from the command line. When this directive is
667662
; enabled, registering these variables consumes CPU cycles and memory each time
668-
; a script is executed. For performance reasons, this feature should be disabled
669-
; on production servers.
663+
; a script is executed. For security reasons, this feature should be disabled
664+
; for non-CLI SAPIs.
670665
; Note: This directive is hardcoded to On for the CLI SAPI
671-
; Default Value: On
672-
; Development Value: Off
673-
; Production Value: Off
666+
; This directive is deprecated.
674667
; https://php.net/register-argc-argv
675-
register_argc_argv = Off
668+
;register_argc_argv = Off
676669

677670
; When enabled, the ENV, REQUEST and SERVER variables are created when they're
678671
; first used (Just In Time) instead of when the script starts. If these

‎php.ini-production

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -129,11 +129,6 @@
129129
; Development Value: 4096
130130
; Production Value: 4096
131131

132-
; register_argc_argv
133-
; Default Value: On
134-
; Development Value: Off
135-
; Production Value: Off
136-
137132
; request_order
138133
; Default Value: None
139134
; Development Value: "GP"
@@ -667,14 +662,12 @@ request_order = "GP"
667662
; that were passed when the script was invoked. These arrays are extremely
668663
; useful when running scripts from the command line. When this directive is
669664
; enabled, registering these variables consumes CPU cycles and memory each time
670-
; a script is executed. For performance reasons, this feature should be disabled
671-
; on production servers.
665+
; a script is executed. For security reasons, this feature should be disabled
666+
; for non-CLI SAPIs.
672667
; Note: This directive is hardcoded to On for the CLI SAPI
673-
; Default Value: On
674-
; Development Value: Off
675-
; Production Value: Off
668+
; This directive is deprecated.
676669
; https://php.net/register-argc-argv
677-
register_argc_argv = Off
670+
;register_argc_argv = Off
678671

679672
; When enabled, the ENV, REQUEST and SERVER variables are created when they're
680673
; first used (Just In Time) instead of when the script starts. If these

‎tests/basic/011.phpt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
--TEST--
22
Testing $argc and $argv handling (GET)
3+
--SKIPIF--
4+
<?php
5+
if(substr(PHP_OS, 0, 3) == 'WIN') die("skip on windows: --INI-- is ignored due to 4b9cd27ff5c0177dcb160caeae1ea79e761ada58");
6+
?>
37
--INI--
48
register_argc_argv=1
59
--GET--

‎tests/basic/011_windows.phpt

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
--TEST--
2+
Testing $argc and $argv handling (GET)
3+
--INI--
4+
register_argc_argv=1
5+
--GET--
6+
foo=ab+cd+ef+123+test
7+
--FILE--
8+
<?php
9+
$argc = $_SERVER['argc'];
10+
$argv = $_SERVER['argv'];
11+
12+
for ($i=0; $i<$argc; $i++) {
13+
echo "$i: ".$argv[$i]."\n";
14+
}
15+
16+
?>
17+
--EXPECT--
18+
0: foo=ab
19+
1: cd
20+
2: ef
21+
3: 123
22+
4: test

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /