New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WP-CLI fails to connect when wp-config.php has database environment variables #3729
Comments
Forgot to mention I'm using I think the right solution here is to just pass NULL for the env parameter. That way it will inherit the environment of the parent PHP process. @danielbachhuber what do you think? |
Oh, huh. Have you tested to verify the environment variables are actually passed through? |
I haven't tested it yet, was going off of the docs here: http://php.net/manual/en/function.proc-open.php Will test shortly. |
What's the easiest way to make a change and test it locally? (sorry, I'm a PHP n00b) |
For now going with installing it as a project and testing it that way |
This fixes wp-cli#3729. proc_open will inherit the parent environment if you pass NULL for the environment parameter (http://php.net/manual/en/function.proc-open.php). I've verified that this works properly by testing this fix against my wp-config that contained environment variables.
@danielbachhuber I tested it locally and verified it works. Please see PR #3730 above. |
Interesting. Learn something new every day! |
This is similar to #2365 which I don't think got properly resolved.
I want my wp-config.php to be stateless so can deploy it to any environment (in this case, I'm deploying it to Docker and AWS Elastic Beanstalk). So I define my DB config settings like this:
This works great in multiple environments, but WP CLI doesn't pick up the settings properly. It looks like the culprit is these lines:
https://github.com/wp-cli/wp-cli/blob/v1.0.0/php/class-wp-cli.php#L1011-L1026
Passing in the new environment into
proc_open
will replace the parent environment, thus replacing any environment variables that exist when invoking the CLI. I'm curious, why does this need to pass a new environment? Couldn't we just pass NULL there to inherit the parent environment?The text was updated successfully, but these errors were encountered: