8000 bug #41148 [Runtime] fix defining $_SERVER[APP_ENV] (nicolas-grekas) · symfony/symfony@c151f76 · GitHub
[go: up one dir, main page]

Skip to content

Commit c151f76

Browse files
bug #41148 [Runtime] fix defining $_SERVER[APP_ENV] (nicolas-grekas)
This PR was merged into the 5.3-dev branch. Discussion ---------- [Runtime] fix defining $_SERVER[APP_ENV] | Q | A | ------------- | --- | Branch? | 5.3 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | Fix #41140 | License | MIT | Doc PR | - Commits ------- e271acc [Runtime] fix defining $_SERVER[APP_ENV]
2 parents 2a87821 + e271acc commit c151f76

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/Symfony/Component/Runtime/SymfonyRuntime.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,20 +88,22 @@ class SymfonyRuntime extends GenericRuntime
8888
*/
8989
public function __construct(array $options = [])
9090
{
91-
if (isset($_SERVER['argv']) && !isset($options['env']) && class_exists(ArgvInput::class)) {
91+
if (isset($options['env'])) {
92+
$_SERVER['APP_ENV'] = $options['env'];
93+
} elseif (isset($_SERVER['argv']) && class_exists(ArgvInput::class)) {
9294
$this->options = $options;
9395
$this->getInput();
9496
}
9597

96-
$_SERVER['APP_ENV'] = $options['env'] ?? $_SERVER['APP_ENV'] ?? $_ENV['APP_ENV'] ?? 'dev';
97-
9898
if (!($options['disable_dotenv'] ?? false) && isset($options['project_dir']) && !class_exists(MissingDotenv::class, false)) {
9999
(new Dotenv())
100100
->setProdEnvs((array) ($options['prod_envs'] ?? ['prod']))
101101
->usePutenv($options['use_putenv'] ?? false)
102102
->bootEnv($options['project_dir'].'/'.($options['dotenv_path'] ?? '.env'), 'dev', (array) ($options['test_envs'] ?? ['test']));
103103
$options['debug'] ?? $options['debug'] = '1' === $_SERVER['APP_DEBUG'];
104104
$options['disable_dotenv'] = true;
105+
} else {
106+
$_SERVER['APP_ENV'] ?? $_SERVER['APP_ENV'] = 'dev';
105107
}
106108

107109
$options['error_handler'] ?? $options['error_handler'] = SymfonyErrorHandler::class;

0 commit comments

Comments
 (0)
0