-
Couldn't load subscription status.
- Fork 8k
Fix GH-20279: register_argc_argv set at 0 on sapi cli after deprecation. #20280
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -118,7 +118,11 @@ static const char HARDCODED_INI[] = | |
| "implicit_flush=1\n" | ||
| "output_buffering=0\n" | ||
| "max_execution_time=0\n" | ||
| "max_input_time=-1\n"; | ||
| "max_input_time=-1\n" | ||
| "register_argc_argv=1\n"; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This was intentionally removed, since the implementation just ignores the INI for the CLI entirely. In practice this will not hardcode the INI anyways, since the |
||
|
|
||
| static const char SERVER_HARDCODED_INI[] = | ||
| "register_argc_argv=1\n"; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The CLI server is not the CLI. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I was confused by this There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The CLI server should not be treated as a CLI SAPI, since its purpose is HTTP requests. The CLI SAPIs are cli and phpdbg.
Yes, the implementation does not actually match the RFC to the letter, but it matches it in intent. What the implementation does, is ignoring the INI setting when So the RFC said "keeping it hardcoded to 1" and the implementation does "ignore the INI", which results in the same outcome, but a simpler and more predictable implementation. This is the relevant commit: 6ea0eb9 /cc @nicolas-grekas |
||
|
|
||
|
|
||
| const opt_struct OPTIONS[] = { | ||
|
|
@@ -1321,6 +1325,8 @@ int main(int argc, char *argv[]) | |
|
|
||
| if (sapi_module_ptr == &cli_sapi_module) { | ||
| php_ini_builder_prepend_literal(&ini_builder, HARDCODED_INI); | ||
| } else { | ||
| php_ini_builder_prepend_literal(&ini_builder, SERVER_HARDCODED_INI); | ||
| } | ||
|
|
||
| sapi_module_ptr->ini_entries = php_ini_builder_finish(&ini_builder); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| --TEST-- | ||
| GH-20279 (register_argc_argv set to off after deprecation.) | ||
| --SKIPIF-- | ||
| <?php | ||
| include "skipif.inc"; | ||
| ?> | ||
| --FILE-- | ||
| <?php | ||
| var_dump(ini_get("register_argc_argv")); | ||
| ?> | ||
| --EXPECT-- | ||
| string(1) "1" |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| --TEST-- | ||
| GH-18582: Allow http_response_code() to clear HTTP start-line | ||
| --SKIPIF-- | ||
| <?php | ||
| include "skipif.inc"; | ||
| ?> | ||
| --FILE-- | ||
| <?php | ||
| include "php_cli_server.inc"; | ||
| php_cli_server_start(<<<'PHP' | ||
| var_dump(ini_get("register_argc_argv")); | ||
| PHP); | ||
| $host = PHP_CLI_SERVER_HOSTNAME; | ||
| $fp = php_cli_server_connect(); | ||
| if (fwrite($fp, "GET / HTTP/1.1\nHost: {$host}\n\n")) { | ||
| while (!feof($fp)) { | ||
| echo fgets($fp); | ||
| } | ||
| } | ||
| fclose($fp); | ||
| --EXPECTF-- | ||
| HTTP/1.1 200 OK | ||
| Host: localhost | ||
| Date: %s | ||
| Connection: close | ||
| X-Powered-By: PHP/%s | ||
| Content-type: text/html; charset=UTF-8 | ||
|
|
||
| string(1) "1" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is an impossible branch. It's also dead code for the CLI.