Bug: WP_ENVIRONMENT_TYPE set doesn't check if constant is already defined #672
Open
Description
Terms
- I have read the guidelines for Contributing to Roots Projects
- This request is not a duplicate of an existing issue
- I have read the docs and followed them (if applicable)
- I have seached the Roots Discourse for answers and followed them (if applicable)
- This is not a personal support request that should be posted on the Roots Discourse community
Description
What's wrong?
Some environments (like Local) set the WP_ENVIRONMENT_TYPE
constant. Bedrock's implementation should probably check for that to avoid a fatal error.
What have you tried?
Local's prepended PHP file can be updated, but a more bulletproof implementation here is likely preferred.
Possible solutions
if (!defined('WP_ENVIRONMENT_TYPE') && !env('WP_ENVIRONMENT_TYPE') && in_array(WP_ENV, ['production', 'staging', 'development'])) {
Config::define('WP_ENVIRONMENT_TYPE', WP_ENV);
}
I'm also not sure what the !env('WP_ENVIRONMENT_TYPE')
check does in that line, since there's no code to convert that exact env value to the constant value, unless WordPress is doing it under the hood (it might be).
Temporary workarounds
Update Local's config
Steps To Reproduce
- Install a Bedrock site in Local
- See fatal error
Expected Behavior
No fatal error
Actual Behavior
Fatal error
Relevant Log Output
No response
Versions
Since PR #668