Skip to content

Drush internal commands do not inherit $_ENV #674

Open
@dotsam

Description

@dotsam

Some Drush commands will call exec() to run another Drush command (updatedb seems to be the main one, but there may be others). Somewhere in here either the load.environment.php from the Composer autoloader is not called, or $_ENV is clobbered in some way.

This was discussed in drush-ops/drush#4407 and the solution that worked for others, and works for me, is using $_SERVER in the settings.php file rather than $_ENV. The php.ini directive variables_order is referenced, and indeed, the comments for the directive indicate that in the php.ini-production file that most distros are based off of, Environment variables are not set by default.

The part I'm not clear on is that php-dotenv is manually populating the $_ENV global when it is called (via the autoloaded file), when a new drush process is exec()'d, it's not calling the Composer autoloader? But ENV vars from the parent process are copied into $_SERVER?

Ultimately, this issue is to see what should be done about $_ENV in .env.example, to see if it should be replaced with $_SERVER, getenv(), or just a note about the variables_order directive added.

Metadata

Metadata

Assignees

No one assigned

    Labels

    State: Needs triageAn issue or PR has not been assessed and requires a triagedrush

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions