Skip to content
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

Env: Allow skipping setting a configuration value by specifying it as null. #41084

Merged
merged 4 commits into from
May 24, 2022

Conversation

dd32
Copy link
Member

@dd32 dd32 commented May 16, 2022

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 containing WP_ENVIRONMENT_TYPE despite it defaulting to local in wp-env.

{
	"config": {
		"WP_ENVIRONMENT_TYPE": null
	}
}

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 special phpunit-wp-config.php that is created, which wp-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 to null. 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

  1. Create a config as exampled above
  2. Run wp-env start
  3. Inspect configuration files, verify constant not present.

Screenshots or screencast

@dd32 dd32 requested a review from noahtallen as a code owner May 16, 2022 07:00
@dd32 dd32 added the [Tool] Env /packages/env label May 16, 2022
Copy link
Member

@noahtallen noahtallen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense to me 👍

@noahtallen
Copy link
Member

Could you add a changelog entry before merging?

@noahtallen
Copy link
Member

This unfortunately needs a rebase now for it to be merged :(

@dd32
Copy link
Member Author

dd32 commented May 24, 2022

@noahtallen I think that'll take care of it.

@noahtallen noahtallen merged commit bf19659 into WordPress:trunk May 24, 2022
@github-actions github-actions bot added this to the Gutenberg 13.4 milestone May 24, 2022
@mburridge mburridge added the Needs Dev Note Requires a developer note for a major WordPress release cycle label Sep 13, 2022
@mburridge
Copy link
Contributor

Added the Needs Dev Note label in case this needs a dev note (either individual or as part of a "misc" dev note) for WP 6.1 release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs Dev Note Requires a developer note for a major WordPress release cycle [Tool] Env /packages/env
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Env: No way to skip setting WP_ENVIRONMENT_TYPE
3 participants