Repository navigation
[6.x] Keep config file overrides out of saved plugin settings - #20624
Merged
Merged
Conversation
Saving a plugin's settings stored the values from config/craft/<handle>.php in project config, replacing the values saved from the control panel. Overridden keys now keep their stored project config values. Amp-Thread-ID: https://ampcode.com/threads/T-01a1cf62-afcb-7744-8cef-6d984cd03ae1 Co-authored-by: Amp <amp@ampcode.com>
[ci skip] Amp-Thread-ID: https://ampcode.com/threads/T-01a1cf62-afcb-7744-8cef-6d984cd03ae1 Co-authored-by: Amp <amp@ampcode.com>
📚 Storybook previews@craftcms/ui — open Storybook No changed components detected in this Storybook. resources/js — open Storybook No changed components detected in this Storybook. |
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.
Description
Saving a plugin's settings no longer writes
config/craft/<handle>.phpoverrides into project config. Settings the config file overrides keep their stored project config value, or stay absent if they had none. Everything else saves as before.In 5.x, overridden fields were rendered
disabled, so they weren't posted, and only posted keys were saved. In 6.x, read-only fields are posted, and the wholevalidationData()was saved. That included the file's values, replacing the CP values. After the config file was removed, the CP values were gone.The live settings model still holds the file's values after saving, so
afterSaveSettings()andPluginSettingsSavedlisteners see the same runtime settings as before. Only the stored project config changes.Evidence
['bar' => 'File bar', 'foo' => 'Submitted']. On6.x, 5 tests intests/Feature/Plugin/fail.After: project config →
['bar' => 'CP bar', 'foo' => 'Submitted']. With no storedbar, it stays absent:['foo' => 'Submitted'].tests/Feature/Plugin/: 103 passed.composer cipasses.Three existing tests asserted that file values were saved to project config. They now assert that file values are left out. The
PluginConfigurationTestone also checks the rows flushed to theprojectconfigtable: the storedbarrow stays"Stored bar"after flushing.Related issues