Skip to content

[6.x] Keep config file overrides out of saved plugin settings - #20624

Merged
riasvdv merged 2 commits into
6.xfrom
bugfix/plugin-settings-config-overrides
Nov 12, 2026
Merged

riasvdv merged 2 commits into
6.xfrom
bugfix/plugin-settings-config-overrides

Conversation

@riasvdv

@riasvdv riasvdv commented Nov 12, 2026

Copy link
Copy Markdown
Contributor

Description

Saving a plugin's settings no longer writes config/craft/<handle>.php overrides 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.

 Plugins::savePluginSettings($plugin, $posted)
   $settings->setAttributes($posted)   # live model still has file overrides merged in
   validate → SavingPluginSettings → beforeSaveSettings()
-  projectConfig.set(plugins.<handle>.settings, validationData())
+  projectConfig.set(plugins.<handle>.settings,
+    validationData() minus keys in config("craft.<handle>")
+    + stored values for those keys)
   afterSaveSettings() → PluginSettingsSaved   # unchanged; they read the live model

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 whole validationData() 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() and PluginSettingsSaved listeners see the same runtime settings as before. Only the stored project config changes.

Evidence

config/craft/test-plugin.php: ['bar' => 'File bar']
project config:               ['foo' => 'CP foo', 'bar' => 'CP bar']
savePluginSettings(['foo' => 'Submitted', 'bar' => 'File bar'])
  • Before: project config → ['bar' => 'File bar', 'foo' => 'Submitted']. On 6.x, 5 tests in tests/Feature/Plugin/ fail.
    After: project config → ['bar' => 'CP bar', 'foo' => 'Submitted']. With no stored bar, it stays absent: ['foo' => 'Submitted']. tests/Feature/Plugin/: 103 passed. composer ci passes.

Three existing tests asserted that file values were saved to project config. They now assert that file values are left out. The PluginConfigurationTest one also checks the rows flushed to the projectconfig table: the stored bar row stays "Stored bar" after flushing.

Related issues

riasvdv and others added 2 commits November 12, 2026 11:04
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>
@github-actions

Copy link
Copy Markdown

📚 Storybook previews

@craftcms/ui — open Storybook

No changed components detected in this Storybook.

resources/js — open Storybook

No changed components detected in this Storybook.

@riasvdv
riasvdv merged commit 57fe187 into 6.x Nov 12, 2026
@riasvdv
riasvdv deleted the bugfix/plugin-settings-config-overrides branch November 12, 2026 11:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant