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

Appearance settings

Commit 29ed061

Browse filesBrowse files
committed
properly handle SYMFONY_DOTENV_VARS being the empty string
1 parent 8d06a8a commit 29ed061
Copy full SHA for 29ed061

File tree

Expand file treeCollapse file tree

2 files changed

+33
-1
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+33
-1
lines changed

‎src/Symfony/Component/Dotenv/Command/DebugCommand.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Dotenv/Command/DebugCommand.php
+7-1Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,13 @@ protected function execute(InputInterface $input, OutputInterface $output): int
8282

8383
private function getVariables(array $envFiles): array
8484
{
85-
$vars = explode(',', $_SERVER['SYMFONY_DOTENV_VARS'] ?? '');
85+
$dotenvVars = $_SERVER['SYMFONY_DOTENV_VARS'] ?? '';
86+
87+
if ('' === $dotenvVars) {
88+
return [];
89+
}
90+
91+
$vars = explode(',', $dotenvVars);
8692
sort($vars);
8793

8894
$output = [];

‎src/Symfony/Component/Dotenv/Tests/Command/DebugCommandTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Dotenv/Tests/Command/DebugCommandTest.php
+26Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ class DebugCommandTest extends TestCase
2525
*/
2626
public function testErrorOnUninitializedDotenv()
2727
{
28+
unset($_SERVER['SYMFONY_DOTENV_VARS']);
29+
2830
$command = new DebugCommand('dev', __DIR__.'/Fixtures/Scenario1');
2931
$command->setHelperSet(new HelperSet([new FormatterHelper()]));
3032
$tester = new CommandTester($command);
@@ -34,6 +36,30 @@ public function testErrorOnUninitializedDotenv()
3436
$this->assertStringContainsString('[ERROR] Dotenv component is not initialized', $output);
3537
}
3638

39+
/**
40+
* @runInSeparateProcess
41+
*/
42+
public function testEmptyDotEnvVarsList()
43+
{
44+
$_SERVER['SYMFONY_DOTENV_VARS'] = '';
45+
46+
$command = new DebugCommand('dev', __DIR__.'/Fixtures/Scenario1');
47+
$command->setHelperSet(new HelperSet([new FormatterHelper()]));
48+
$tester = new CommandTester($command);
49+
$tester->execute([]);
50+
$output = $tester->getDisplay();
51+
52+
$expectedFormat = <<<'OUTPUT'
53+
%a
54+
---------- ------- ------------ ------%S
55+
Variable Value .env.local .env%S
56+
---------- ------- ------------ ------%S
57+
%a
58+
OUTPUT;
59+
60+
$this->assertStringMatchesFormat($expectedFormat, $output);
61+
}
62+
3763
public function testScenario1InDevEnv()
3864
{
3965
$output = $this->executeCommand(__DIR__.'/Fixtures/Scenario1', 'dev');

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.