Should modules that provide content types be uninstallable / reinstallable?
This stems from localgov_news, and from https://github.com/localgovdrupal/localgov_news/pull/119
The PR is about making all existing config be enforced so it uninstalls. The node and field types of localgov_news are already enforced. This means that when localgov_news is uninstalled, the content type for the news is also uninstalled. This can be a problem if there are existing content of provided type.
See https://github.com/localgovdrupal/localgov_news/issues/120
Other content types, notablly localgov_services, do not enforce config. Instead they will leave the services content types (landing, sub landing, page) and associated fields intact. This does mean that those modules cannot be reinstalled untill the provided config is deleted.
See also https://github.com/localgovdrupal/localgov_directories/pull/392
We could look at creating a module uninstall validator using the Drupal\Core\Extension\ModuleUninstallValidatorInterface and inform the users that the module cannot be uninstalled as content exists for the news content type. This way it's a user decision to remove all the content before uninstalling the module.
What are our use cases here?
Like with the content and the content types left in place site developers can ... Forcing site developers to remove all content to be able to disable and re-enable modules because...
We could look at creating a module uninstall validator using the Drupal\Core\Extension\ModuleUninstallValidatorInterface and inform the users that the module cannot be uninstalled as content exists for the news content type. This way it's a user decision to remove all the content before uninstalling the module.
MT: We should certainly check that we're not leaving orphaned content in the db before removing the config.
What are our use cases here?
Like with the content and the content types left in place site developers can ... Forcing site developers to remove all content to be able to disable and re-enable modules because...
I think in general, letting a module be uninstalled completely and then reinstalled cleanly is the right thing to do. It lets people experiment without fear of things breaking.
If you'd like a specific example, some of the early releases of publications didn't uninstall cleanly, and meant that a couple of councils who were really helpful and tried out early builds got bitten by not being able to install the first stable release. Ok, they arguably shouldn't have put an alpha release into production, but I think that we should do the right thing and make sure that people doing that shouldn't have a bad time, even if we wouldn't recommend it.
If we are going to do this, let's make sure there's a massive warning on the uninstall page saying "If you uninstall this module, you will lose all your content from
If you try to uninstall this module when there are already news articles, those nodes will still exist and throw as WSOD. If we are going to have this module being uninstallable and delete content types, we should prevent uninstallation if content exists.
https://github.com/localgovdrupal/localgov_news/issues/120