Description
getenv
and putenv
are considered not threadsafe. As a result,
We should expose a way (similar to symphony's usePutenv
function) to use the threadsafe version ($_ENV
) instead.
As @DracoBlue mentioned in #429:
The current version of google auth library php uses getenv/putenv to read and set environment variables in php. But the function putenv is not threadsafe, which made libraries (Dotenv https://github.com/symfony/dotenv/blob/6.2/Dotenv.php#L61 and phpdotenv https://github.com/vlucas/phpdotenv#putenv-and-getenv) to disable putenv support by default. Frameworks like symfony (deprecated in 4.3 symfony/symfony#31062 and removed in 5.0) and also in laravel there was a similiar solution to not use it anymore directly (vlucas/phpdotenv#76).
Thus here is a pull request to change all the ocurences of:
getenv($variable)
toarray_key_exists($variable, $_ENV) ? $_ENV[$variable] : false
putenv($variable)
tounset($_ENV[$variable])
putenv($variable . "=")
to$_ENV[$variable]=''
putenv($variable . "=" . $value)
to$_ENV[$variable]=$value
Threads about this:
- https://bugs.php.net/bug.php?id=74143 (putenv does not work if fast cgi sets the variable!)
- [Dotenv] Deprecate useage of "putenv" symfony/symfony#31062
- Changing process environment unsafe on multithreaded servers vlucas/phpdotenv#76
- .env issue with PHP thread-safe laravel/framework#7354
- laravel/framework@866a8cf
- BUG Replace phpdotenv with thread-safe replacement silverstripe/silverstripe-framework#7484
- Laravel 5.8 update breaks third-party composer libraries laravel/framework#27949