8000 feat: add support for using $_ENV instead of getenv/putenv · Issue #432 · googleapis/google-auth-library-php · GitHub
[go: up one dir, main page]

Skip to content
feat: add support for using $_ENV instead of getenv/putenv #432
Closed
@bshaffer

Description

@bshaffer

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) to array_key_exists($variable, $_ENV) ? $_ENV[$variable] : false
  • putenv($variable) to unset($_ENV[$variable])
  • putenv($variable . "=") to $_ENV[$variable]=''
  • putenv($variable . "=" . $value) to $_ENV[$variable]=$value

Threads about this:

Metadata

Metadata

Assignees

No one assigned

    Labels

    lang: phpIssues specific to PHP.priority: p2Moderately-important priority. Fix may not be included in next release.type: feature request‘Nice-to-have’ improvement, new feature or different behavior or design.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0