openeuropa / epoetry-client

PHP client for the ePoetry service.
European Union Public License 1.2
2 stars 3 forks source link

fix: replace `getenv` with `$_ENV` #78

Closed drupol closed 1 year ago

drupol commented 1 year ago

Hi colleagues,

The GROW team reported that they are unable to execute bin/epoetry on their server. I also successfully replicated the issue locally using the current 2.x branch and PHP 8.2.10 (ZTS or NTS). The failure appears to come from the usage of getenv to retrieve environment variables.

Steps to Reproduce

  1. Navigate to ~/<dirs>/epoetry-client
  2. Run bin/epoetry
Fatal error: Uncaught InvalidArgumentException: Invalid environment provided to "OpenEuropa\EPoetry\Console\AppKernel": the environment cannot be empty. in /home/devlin/Code/b4/ecphp/epoetry-client/vendor/symfony/http-kernel/Kernel.php:92

The issue appears to be related to calls made using getenv. This approach is generally discouraged as getenv and putenv are not thread-safe. The PHP community and developers often use superglobal variables $_ENV or $_SERVER to obtain environment variables.

For reference, the Symfony team has also transitioned to prioritizing superglobal variables for obtaining environment variables (see this commit).

Suggested Fix

drupol commented 1 year ago

Thanks