bug #38166 [Console] work around disabled putenv() (SenTisso)

This PR was merged into the 4.4 branch.

Discussion
----------

[Console] work around disabled putenv()

If this is set to true, then putenv functions simply won't be run in this script, making this function usable on servers, where putenv is disabled

| Q             | A
| ------------- | ---
| Branch?       | 4.4
| Bug fix?      | no
| New feature?  | yes <!-- please update src/**/CHANGELOG.md files -->
| Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files -->
| License       | MIT
| Doc PR        | symfony/symfony-docs#... <!-- required for new features -->

Commits
-------

d3f909bff3 [Console] work around disabled putenv()
This commit is contained in:
Fabien Potencier 2020-09-15 13:40:23 +02:00
commit e608d05c69

View File

@ -114,8 +114,10 @@ class Application implements ResetInterface
*/
public function run(InputInterface $input = null, OutputInterface $output = null)
{
putenv('LINES='.$this->terminal->getHeight());
putenv('COLUMNS='.$this->terminal->getWidth());
if (\function_exists('putenv')) {
@putenv('LINES='.$this->terminal->getHeight());
@putenv('COLUMNS='.$this->terminal->getWidth());
}
if (null === $input) {
$input = new ArgvInput();
@ -980,7 +982,9 @@ class Application implements ResetInterface
$input->setInteractive(false);
}
putenv('SHELL_VERBOSITY='.$shellVerbosity);
if (\function_exists('putenv')) {
@putenv('SHELL_VERBOSITY='.$shellVerbosity);
}
$_ENV['SHELL_VERBOSITY'] = $shellVerbosity;
$_SERVER['SHELL_VERBOSITY'] = $shellVerbosity;
}