Refactor wp config create to set config values through WPConfigTransformer#226
Draft
Copilot wants to merge 8 commits into
Draft
Refactor wp config create to set config values through WPConfigTransformer#226Copilot wants to merge 8 commits into
wp config create to set config values through WPConfigTransformer#226Copilot wants to merge 8 commits into
Conversation
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Refactor config command to always validate in config transformer library
Refactor May 27, 2026
wp config create to set config values through WPConfigTransformer
This comment was marked as resolved.
This comment was marked as resolved.
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
This comment was marked as resolved.
This comment was marked as resolved.
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR refactors wp config create so that config values are written via WPConfigTransformer, aligning the create flow with the transformer-backed config set/update behavior and centralizing escaping/formatting logic in the transformer library.
Changes:
- Render
wp-config.mustachewith baseline defaults (and salt placeholders when generating salts), then apply user-provided DB/table-prefix values viaWPConfigTransformer::update(). - Apply locally generated salts via transformer updates, while preserving the remote-salts fallback when local generation fails.
- Add a feature scenario to validate special-character handling for
DB_CHARSETthrough the transformer-backed write path.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
src/Config_Command.php |
Refactors config create to render defaults first and then write user-provided values/salts using WPConfigTransformer. |
features/config-create.feature |
Adds coverage ensuring DB_CHARSET values with quotes/backslashes are written/read correctly via transformer. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+392
to
+410
| $config_transformer->update( | ||
| $entry['type'], | ||
| $entry['name'], | ||
| $assoc_args[ $arg_name ], | ||
| [ 'add' => true ] | ||
| ); | ||
|
|
||
| if ( false !== strpos( $assoc_args[ $arg_name ], '\\' ) ) { | ||
| $config_transformer->remove( $entry['type'], $entry['name'] ); | ||
| $config_transformer->add( | ||
| $entry['type'], | ||
| $entry['name'], | ||
| $assoc_args[ $arg_name ], | ||
| [ | ||
| 'anchor' => $entry['anchor'], | ||
| 'placement' => 'before', | ||
| ] | ||
| ); | ||
| } |
Comment on lines
+430
to
+434
| } catch ( Exception $exception ) { | ||
| WP_CLI::error( "Could not process the '{$wp_config_file_name}' transformation.\nReason: {$exception->getMessage()}" ); | ||
| } | ||
|
|
||
| WP_CLI::success( "Generated '{$wp_config_file_name}' file." ); |
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
wp config createstill had a separate value-writing path from the transformer-backed commands, which duplicated escaping/validation behavior and made new validation logic hard to centralize. This change makescreatea thin wrapper: render defaults first, then apply requested values throughwp-cli/wp-config-transformer.Create flow now routes value writes through transformer
wp-config.mustachewith baseline defaults (including empty placeholders for salts when needed).WPConfigTransformer::update().WPConfigTransformer::update()when salts are generated.Removed create-specific escaping path
escape_config_value()path used only bycreate.Focused feature coverage for transformer-path escaping
config createfeature scenario covering special-character handling forDB_CHARSETto ensure values written through the transformer are preserved and readable viawp config get.