Skip to content

Commit 2c35056

Browse files
[Runtime] Negate register_argc_argv when its On
1 parent 46fd79d commit 2c35056

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

SymfonyRuntime.php

+6-4
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,12 @@ public function __construct(array $options = [])
9393
$envKey = $options['env_var_name'] ??= 'APP_ENV';
9494
$debugKey = $options['debug_var_name'] ??= 'APP_DEBUG';
9595

96+
if (isset($_SERVER['argv']) && !empty($_GET)) {
97+
// register_argc_argv=On is too risky in web servers
98+
$_SERVER['argv'] = [];
99+
$_SERVER['argc'] = 0;
100+
}
101+
96102
if (isset($options['env'])) {
97103
$_SERVER[$envKey] = $options['env'];
98104
} elseif (empty($_GET) && isset($_SERVER['argv']) && class_exists(ArgvInput::class)) {
@@ -203,10 +209,6 @@ protected static function register(GenericRuntime $runtime): GenericRuntime
203209

204210
private function getInput(): ArgvInput
205211
{
206-
if (!empty($_GET) && filter_var(ini_get('register_argc_argv'), \FILTER_VALIDATE_BOOL)) {
207-
throw new \Exception('CLI applications cannot be run safely on non-CLI SAPIs with register_argc_argv=On.');
208-
}
209-
210212
if (isset($this->input)) {
211213
return $this->input;
212214
}

0 commit comments

Comments
 (0)