Skip to content

Commit 9d39446

Browse files
Revert "bug #29154 [FrameworkBundle] Define APP_ENV/APP_DEBUG from argv via Application::bootstrapEnv() (chalasr)"
This reverts commit 9253199de1d04ca591a051484bbdff861c1d542c, reversing changes made to 664a032940a02ef9969345797cc3683ea56cf562.
1 parent c4179b0 commit 9d39446

File tree

3 files changed

+2
-90
lines changed

3 files changed

+2
-90
lines changed

CHANGELOG.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,8 @@ CHANGELOG
1515
* Removed the `framework.messenger.encoder` and `framework.messenger.decoder` options. Use the `framework.messenger.serializer.id` option to replace the Messenger serializer.
1616
* Deprecated the `ContainerAwareCommand` class in favor of `Symfony\Component\Console\Command\Command`
1717
* Made `debug:container` and `debug:autowiring` ignore backslashes in service ids
18-
* Deprecated the `--env` console option and its "-e" shortcut, set the "APP_ENV" environment variable
19-
or use `Application::bootstrapEnv()` instead.
20-
* Deprecated the `--no-debug` console option, set the "APP_DEBUG" environment variable to "0"
21-
or use `Application::bootstrapEnv()` instead.
18+
* Deprecated `--env` and `--no-debug` console options, define the `APP_ENV` and `APP_DEBUG` environment variables or
19+
parse input arguments as done in https://github.com/symfony/recipes/blob/master/symfony/console/3.3/bin/console instead
2220
* Deprecated the `Templating\Helper\TranslatorHelper::transChoice()` method, use the `trans()` one instead with a `%count%` parameter
2321
* Deprecated `CacheCollectorPass`. Use `Symfony\Component\Cache\DependencyInjection\CacheCollectorPass` instead.
2422
* Deprecated `CachePoolClearerPass`. Use `Symfony\Component\Cache\DependencyInjection\CachePoolClearerPass` instead.

Console/Application.php

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -207,35 +207,6 @@ protected function registerCommands()
207207
}
208208
}
209209

210-
/**
211-
* Defines the "APP_ENV" and "APP_DEBUG" environment variables by consuming --env and --no-debug from the command line arguments.
212-
*/
213-
public static function bootstrapEnv(array &$argv)
214-
{
215-
for ($i = 0; $i < \count($argv) && '--' !== $v = $argv[$i]; ++$i) {
216-
if ('--no-debug' === $v) {
217-
putenv('APP_DEBUG='.$_SERVER['APP_DEBUG'] = $_ENV['APP_DEBUG'] = '0');
218-
$argvUnset[$i] = true;
219-
break;
220-
}
221-
}
222-
223-
for ($i = 0; $i < \count($argv) && '--' !== $v = $argv[$i]; ++$i) {
224-
if (!$v || '-' !== $v[0] || !preg_match('/^-(?:-env(?:=|$)|e=?)(.*)$/D', $v, $v)) {
225-
continue;
226-
}
227-
if (!empty($v[1]) || !empty($argv[1 + $i])) {
228-
putenv('APP_ENV='.$_SERVER['APP_ENV'] = $_ENV['APP_ENV'] = empty($v[1]) ? $argv[1 + $i] : $v[1]);
229-
$argvUnset[$i] = $argvUnset[$i + empty($v[1])] = true;
230-
}
231-
break;
232-
}
233-
234-
if (!empty($argvUnset)) {
235-
$argv = array_values(array_diff_key($argv, $argvUnset));
236-
}
237-
}
238-
239210
private function renderRegistrationErrors(InputInterface $input, OutputInterface $output)
240211
{
241212
if ($output instanceof ConsoleOutputInterface) {

Tests/Console/ApplicationTest.php

Lines changed: 0 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -283,63 +283,6 @@ private function createBundleMock(array $commands)
283283

284284
return $bundle;
285285
}
286-
287-
public function testBootstrapEnv()
288-
{
289-
$argv = array('--no-debug', '--env=testBootstrapEnv', 'foo=bar');
290-
Application::bootstrapEnv($argv);
291-
292-
$this->assertSame($_SERVER['APP_DEBUG'], '0');
293-
$this->assertSame($_ENV['APP_DEBUG'], '0');
294-
$this->assertSame('0', getenv('APP_DEBUG'));
295-
$this->assertSame('testBootstrapEnv', $_SERVER['APP_ENV']);
296-
$this->assertSame('testBootstrapEnv', $_ENV['APP_ENV']);
297-
$this->assertSame('testBootstrapEnv', getenv('APP_ENV'));
298-
$this->assertSame(array('foo=bar'), $argv);
299-
300-
unset($_SERVER['APP_ENV']);
301-
unset($_ENV['APP_ENV']);
302-
putenv('APP_ENV');
303-
unset($_SERVER['APP_DEBUG']);
304-
unset($_ENV['APP_DEBUG']);
305-
putenv('APP_DEBUG');
306-
307-
$argv = array('--env', 'testBootstrapEnv', 'foo=bar');
308-
Application::bootstrapEnv($argv);
309-
310-
$this->assertSame('testBootstrapEnv', $_SERVER['APP_ENV']);
311-
$this->assertSame('testBootstrapEnv', $_ENV['APP_ENV']);
312-
$this->assertSame('testBootstrapEnv', getenv('APP_ENV'));
313-
$this->assertSame(array('foo=bar'), $argv);
314-
315-
unset($_SERVER['APP_ENV']);
316-
unset($_ENV['APP_ENV']);
317-
putenv('APP_ENV');
318-
319-
$argv = array('-e', 'testBootstrapEnv', 'foo=bar');
320-
Application::bootstrapEnv($argv);
321-
322-
$this->assertSame('testBootstrapEnv', $_SERVER['APP_ENV']);
323-
$this->assertSame('testBootstrapEnv', $_ENV['APP_ENV']);
324-
$this->assertSame('testBootstrapEnv', getenv('APP_ENV'));
325-
$this->assertSame(array('foo=bar'), $argv);
326-
327-
unset($_SERVER['APP_ENV']);
328-
unset($_ENV['APP_ENV']);
329-
putenv('APP_ENV');
330-
331-
$argv = array('-e=testBootstrapEnv', 'foo=bar');
332-
Application::bootstrapEnv($argv);
333-
334-
$this->assertSame('testBootstrapEnv', $_SERVER['APP_ENV']);
335-
$this->assertSame('testBootstrapEnv', $_ENV['APP_ENV']);
336-
$this->assertSame('testBootstrapEnv', getenv('APP_ENV'));
337-
$this->assertSame(array('foo=bar'), $argv);
338-
339-
unset($_SERVER['APP_ENV']);
340-
unset($_ENV['APP_ENV']);
341-
putenv('APP_ENV');
342-
}
343286
}
344287

345288
class ThrowingCommand extends Command

0 commit comments

Comments
 (0)