Env: Allow skipping setting a configuration value by specifying it as null. #41084
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #41083
What?
This PR allows for wp-env to have a config configuration value skipped, if defined as null.
For example, this would result in the
wp-config.php
NOT containingWP_ENVIRONMENT_TYPE
despite it defaulting tolocal
in wp-env.Why?
Under some edge-cases, it may be wanted to skip setting a constant, as that makes it difficult to perform unit testing which may vary depending on it's value.
Given this constant is for a function that cannot be filtered, not having a way to avoid it being set results in unit testing pain.
Simply running
wp config delete CONSTANT
cannot be used for unit testing purposes either, due to the specialphpunit-wp-config.php
that is created, whichwp-cli
cannot operate on.How?
While there might be real reasons to set a constant to
false
or an empty string, I can't see the need to set one tonull
. Skipping the constant in the case of null seems reasonable to me.Another possibility is that for null keys, it should be a
wp config delete
command that is run instead. But that seemed like it was solving something that wasn't yet a problem.Testing Instructions
Screenshots or screencast