Problem/Motivation
FloodControlSettingsForm
loads and saves data to a contact.settings
config object that belongs to the core Contact module. This can lead to issues with e.g. config sync as sync will fail if Flood Control is enabled and Contact is not enabled.
Steps to reproduce
1. Install Flood Control module.
2. Disable core Contact module.
3. Save the Flood Control module settings form.
4. Export the site config.
5. Attempt to import the site config.
This should fail with an error similar to :
[error] Drupal\Core\Config\ConfigImporterException: There were errors validating the config synchronization.
Configuration <em class="placeholder">contact.settings</em> depends on the <em class="placeholder">Contact</em> module that will not be installed after import. in Drupal\Core\Config\ConfigImporter->validate() (line 755 of /[...]/docroot/core/lib/Drupal/Core/Config/ConfigImporter.php).
In ConfigImportCommands.php line 357:
The import failed due to the following reasons:
Configuration <em class="placeholder">contact.settings</em> depends on the <em class="placeholder">Contact</em> module that will not be i
nstalled after import.
Proposed resolution
Only offer and save Contact specific settings if the Contact module is enabled.
Incidentally -- why are these config settings available but not configurable in the core Contact module config object anyway? Weird.
Remaining tasks
Create patch.
User interface changes
None.
API changes
None.
Data model changes
None.
Comment | File | Size | Author |
---|---|---|---|
#2 | 3192020-2.patch | 5.17 KB | wells |
Issue fork flood_control-3192020
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
wellsAttaching patch to prevent relevant form fields from appearing and the config object from saving if the Contact module is not enabled.
Comment #3
cdesautels CreditAttribution: cdesautels commentedTried the patch 3192020-1. Made no difference. Config export still exports the contact.setting.yml.
Comment #4
wellsDid you already have the config saved? If so, this patch will indeed not do anything. It only prevents saving the config if the Contact module is not enabled. I.e. if you are already using the Flood Control module and have already saved the form before applying this patch, it will have no effect on future saves of the form so the contact config will still exist.
I'll see this back to Needs work for anyone who wants to take it further. I imagine a post update hook would be needed.
Comment #7
bobbygryzyngerI'm also encountering this issue. I added the patch from #2 to the issue fork and added a post_update hook to remove the contact module settings if the module is not enabled.
Comment #8
bobbygryzyngerMarking for review.
Comment #9
brandonratz CreditAttribution: brandonratz as a volunteer commentedPatch #2 works to prevent export if config doesn't initially exist
1.
drush cdel contact.settings
2. Patch
3.
drush cex
No
contact.settings.yml
exists in exported configComment #10
bygeoffthompson CreditAttribution: bygeoffthompson commentedSimilar (but different!) issue and test.
I am moving a site (with Core's Contact disabled) from flood_unblock to flood_control. Without Patch #2 here I received an Undefined Index: flood error noted in this closed issue https://www.drupal.org/project/flood_control/issues/3195497
Patch #2 here resolved my issue re: the undefined index: flood, exactly as batigolix theorized.
Additionally I no longer see Contact related configuration being exported with Patch #2 applied (as expected because my site does not have the module enabled). Thanks for this improvement!
Comment #11
bygeoffthompson CreditAttribution: bygeoffthompson commentedComment #13
JeroenTThe code in the MR no longer applied, so I merged 2.0.x into that branch and I added some test coverage for the settings form.
Comment #14
milovan CreditAttribution: milovan commentedI confirm #13 works.
Thanks!
Comment #15
VladimirAusI tested the patch and can confirm #13 is working.
+1 for release.
Comment #16
AnybodyConfirming RTBC. Can we have a new stable release please @maintainer? :) Great work!
Comment #19
batigolixThanks everybody for helping out.
Comment #20
AnybodyThank YOU very very much for the commit and new release @batigolix :)