Skip to content

Commit

Permalink
bug #52428 [HttpKernel] Preventing error 500 when function putenv is …
Browse files Browse the repository at this point in the history
…disabled (ShaiMagal)

This PR was squashed before being merged into the 5.4 branch.

Discussion
----------

[HttpKernel] Preventing error 500 when function putenv is disabled

| Q             | A
| ------------- | ---
| Branch?       | 5.4
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Issues        |
| License       | MIT

**Description:**
Some webhostings are blocking function "**putenv**". So, it will show error 500 Error (UndefinedFunction) with text:
Attempted to call function "putenv" from namespace "Symfony\Component\HttpKernel

This PR is checking callability of putenv first, so preventing error 500.

**How to test?**
  -> php.ini - disabled_functions=putenv
  -> enable debug
  - >Then you will see error 500
  -> After this PR/commit, it's without problem.

For example it's very common problem for PrestaShop users. (PrestaShop is using Symfony)

Commits
-------

e4be02a [HttpKernel] Preventing error 500 when function putenv is disabled
  • Loading branch information
fabpot committed Nov 2, 2023
2 parents 6765a43 + e4be02a commit b421063
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/Symfony/Component/HttpKernel/Kernel.php
Expand Up @@ -778,7 +778,9 @@ private function preBoot(): ContainerInterface
$this->startTime = microtime(true);
}
if ($this->debug && !isset($_ENV['SHELL_VERBOSITY']) && !isset($_SERVER['SHELL_VERBOSITY'])) {
putenv('SHELL_VERBOSITY=3');
if (\function_exists('putenv')) {
putenv('SHELL_VERBOSITY=3');
}
$_ENV['SHELL_VERBOSITY'] = 3;
$_SERVER['SHELL_VERBOSITY'] = 3;
}
Expand Down

0 comments on commit b421063

Please sign in to comment.