Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Currently, I don't think we really take care of enabled and disabled modules in any way. In D7, we currently mark modules as required by Drupal when they provide a service class (now: backend plugin) or datasource we are using in a server or index (like the Fields module does with modules defining used fields). Before that, I think we tried to delete indexes/servers when the module which provided their datasource/service class disappeared.
One of these two should also be done in D8 (or maybe some third option).
Comment | File | Size | Author |
---|---|---|---|
#8 | 2257081-8.patch | 13.9 KB | amateescu |
#7 | Confirm uninstall Site Install.png | 29.33 KB | Berdir |
Comments
Comment #1
BerdirCore has a very strict dependency system for config, and each config entity can depend on N modules and other config entities. This ensures that configuration is automatically removed when dependencies are removed (This is unfortunately very strict, the nice thing is that it shows you on the uninstall screen what it will remove).
The system will also ensure that configuration is installed/synced in the right order, which is currently a problem. So we should make the index depend on the server (right now indexes are installed before servers because it's alphabetical if there is no explicit dependency) and things like fields, plugin providers and so on. Entity form/view displays are relatively complex core examples (calculateDependencies() Figuring that out will not be trivial, as we'll need to ask the data source what dependencies we have through the enabled fields...
Comment #2
amateescu CreditAttribution: amateescu commentedMe and @Berdir were just discussing this problem a few hours ago :) The index not depending on the server is fixed in #2257095: The database backend doesn't create columns when servers and indexes are created from default config because it was needed in order to fix the first bug there, and I'll work on the remaining problems.
Comment #3
amateescu CreditAttribution: amateescu commentedComment #4
drunken monkeyAh, excellent, great to hear!
I was aware of this core feature, yes, I just didn't know if we are using it (or if that's unavoidable).
Also, for us I think it wouldn't be appropriate to delete indexes when one datasource plugin or the current tracker plugin got removed. So, is there any way to avoid this?
(Also, would the dependency mean that when the Solr module gets uninstalled, all indexes lying on a Solr server would get deleted as well? That would be something we should definitely try to avoid, or at least warn against.)
Comment #5
amateescu CreditAttribution: amateescu commentedHere's a patch which makes Index and Server return all their dependencies, including field and instance config entities coming from each datasource of an index.
I'll think about how to best handle #4 after lunch :)
Comment #6
BerdirYay!
I can confirm that with the patch, I can add an index with server to the default config folder of a module/profile which already contains fields that the index depends on, which didn't work before.
I did notice a few things when testing, but they're not related to this issue I think, will open separate issues where it makes sense/when I can reproduce:
1. Looks like hook_cron() doesn't work yet, because things aren't indexed when I run cron?
2. Sometimes I get weird errors/exceptions because the server forgets about the index or something, then I had to edit, remove server, edit again, add server and then enable again, then it worked again.
3. Those edits and it not working initially resulted in my tables getting numeric suffixes, for example, I have now tables like search_api_db_{index}_1, and some field tables had up to _4 as a suffix, interestingly, despite that then being the default config after I re-installed, it went back to no suffix except the index table?
Comment #7
BerdirRe #4:
I don't think it deletes automatically right now except when you uninstall a module, then it explicitly looks at your configuration dependencies and tells you what it is going to remove. See screenshot (the configuration fieldset is hidden by default, though)
We can use that dependency API on the delete confirmation form to easily find the indexes that depend on us and then remove them from the server (as we do now, except the UI part?)
I don't think we can prevent this if modules are uninstalled that provide processors or fields, though. Will ask @alexpott to comment...
Comment #8
amateescu CreditAttribution: amateescu commentedRemoved manual creation of fields and instances from SearchApiDbTest in favor of default config files.
The problem described in #4 is not really about the delete confirmation form, but about that screenshot posted in #7, where we don't want to remove the index when a module that contains its server backeng is uninstalled. I'm not sure what to do there, we do need the dependency at install time, but we don't want it (somehow) at uninstall time.
I'll wait for some advice from @alexpott on how we can do that :)
Comment #9
BerdirI opened #2260457: Allow config entities to remove dependent configuration keys when dependencies are deleted due to module uninstall because core has similar problems with entity view/form displays, which shouldn't be deleted if you remove a single field.
Comment #10
amateescu CreditAttribution: amateescu commentedI looked into solving the backend-providing-module uninstall problem and it's not possible without the core issue that @Berdir mentioned above.I'm going to commit this patch so we have proper dependencies declared now and mark this issue postponed to implement the self-healing process when we have it :)
Comment #12
amateescu CreditAttribution: amateescu commentedCommitted a small followup to use the new trait available from #2266859: Move the dependency calculation helper methods from ConfigEntityBase to generic traits.
http://drupalcode.org/sandbox/daeron/2091893.git/commit/3a44cdafedce6c88...
Comment #34
Berdir20 commit references later, the core issue finally made it in, so we can unpostpone this and implement the new method. See changes to EntityDisplayBase in #2260457: Allow config entities to remove dependent configuration keys when dependencies are deleted due to module uninstall as an example.
Comment #35
drunken monkeyExcellent, good to know!
Maybe something to tackle in Amsterdam – unless someone wants to take a shot at it before then.
Comment #37
drunken monkeyComment #38
drunken monkeyAlready implemented this in some other issue(s).