Skip to content

Commit 057ff35

Browse files
authored
sapi/cli: Print non-default INI settings for --ini=diff (php#17762)
This is a follow-up for php#17459, updating the command-line flag to not modify the behavior of `--ini`.
1 parent 0df9974 commit 057ff35

File tree

4 files changed

+19
-5
lines changed

4 files changed

+19
-5
lines changed

NEWS

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ PHP NEWS
33
?? ??? ????, PHP 8.5.0alpha1
44

55
- CLI:
6-
. Extended --ini to print INI settings changed from the builtin default.
6+
. Add --ini=diff to print INI settings changed from the builtin default.
77
(timwolla)
88
. Drop support for -z CLI/CGI flag. (nielsdos)
99
. Fixed GH-17956 - development server 404 page does not adapt to mobiles.

UPGRADING

+2-1
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,8 @@ PHP 8.5 UPGRADE NOTES
136136
- CLI:
137137
. Trying to set a process title that is too long with cli_set_process_title()
138138
will now fail instead of silently truncating the given title.
139-
. --ini will now print INI settings changed from the builtin default.
139+
. Added a new --ini=diff option to print INI settings changed from the builtin
140+
default.
140141

141142
========================================
142143
4. Deprecated Functionality

sapi/cli/cli.h

+1
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ typedef enum php_cli_mode {
4949
PHP_CLI_MODE_REFLECTION_EXT_INFO = 11,
5050
PHP_CLI_MODE_REFLECTION_ZEND_EXTENSION = 12,
5151
PHP_CLI_MODE_SHOW_INI_CONFIG = 13,
52+
PHP_CLI_MODE_SHOW_INI_DIFF = 14,
5253
} php_cli_mode;
5354

5455
typedef struct php_cli_server_context {

sapi/cli/php_cli.c

+15-3
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ const opt_struct OPTIONS[] = {
158158
{13, 1, "rzendextension"},
159159
{14, 1, "ri"},
160160
{14, 1, "rextinfo"},
161-
{15, 0, "ini"},
161+
{15, 2, "ini"},
162162
/* Internal testing option -- may be changed or removed without notice,
163163
* including in patch releases. */
164164
{16, 1, "repeat"},
@@ -500,6 +500,7 @@ static void php_cli_usage(char *argv0)
500500
" starts with - or script is read from stdin\n"
501501
"\n"
502502
" --ini Show configuration file names\n"
503+
" --ini=diff Show INI entries that differ from the built-in default\n"
503504
"\n"
504505
" --rf <name> Show information about function <name>.\n"
505506
" --rc <name> Show information about class <name>.\n"
@@ -822,7 +823,15 @@ static int do_cli(int argc, char **argv) /* {{{ */
822823
reflection_what = php_optarg;
823824
break;
824825
case 15:
825-
context.mode = PHP_CLI_MODE_SHOW_INI_CONFIG;
826+
if (php_optarg) {
827+
if (strcmp(php_optarg, "diff") == 0) {
828+
context.mode = PHP_CLI_MODE_SHOW_INI_DIFF;
829+
} else {
830+
param_error = "Unknown argument for --ini\n";
831+
}
832+
} else {
833+
context.mode = PHP_CLI_MODE_SHOW_INI_CONFIG;
834+
}
826835
break;
827836
case 16:
828837
num_repeats = atoi(php_optarg);
@@ -1101,7 +1110,10 @@ static int do_cli(int argc, char **argv) /* {{{ */
11011110
zend_printf("Loaded Configuration File: %s\n", php_ini_opened_path ? php_ini_opened_path : "(none)");
11021111
zend_printf("Scan for additional .ini files in: %s\n", php_ini_scanned_path ? php_ini_scanned_path : "(none)");
11031112
zend_printf("Additional .ini files parsed: %s\n", php_ini_scanned_files ? php_ini_scanned_files : "(none)");
1104-
zend_printf("\n");
1113+
break;
1114+
}
1115+
case PHP_CLI_MODE_SHOW_INI_DIFF:
1116+
{
11051117
zend_printf("Non-default INI settings:\n");
11061118
zend_ini_entry *ini_entry;
11071119
HashTable *sorted = zend_array_dup(EG(ini_directives));

0 commit comments

Comments
 (0)