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.
Problem/Motivation
$ drush pmu simplenews
simplenews is a required extension and can't be uninstalled. Reason: Fields type(s) in use.
There were no extensions that could be uninstalled.
This is at least bad DX.
Proposed resolution
Remaining tasks
User interface changes
API changes
Comment | File | Size | Author |
---|---|---|---|
#7 | can_not_uninstall-2418659-7-interdiff.txt | 5.98 KB | mbovan |
#7 | can_not_uninstall-2418659-7.patch | 7.17 KB | mbovan |
| |||
#5 | can_not_uninstall-2418659-5-interdiff.txt | 1.02 KB | mbovan |
#5 | can_not_uninstall-2418659-5.patch | 6.89 KB | mbovan |
| |||
#4 | prepare_uninstall_data.png | 43.58 KB | mbovan |
Comments
Comment #1
BerdirIt is, but I don't really know what to do about it.
You have to manually delete those fields first, then run cron, then you should be able to remove it. Assuming you do not have any subscribers left. Core is very strict on this right now.
Only option that would help a bit would be to move the fields to a simplenews_fields submodule, so you can uninstall simplenews, that would remove the fields, then remove the simplenews_fields modue.
Comment #2
BerdirThis seems like a problem we need to resolve before a stable version.
Comment #3
miro_dietikerThe origin of this problem is a core limitation. Core should fix this.
Until this happens, we can add a workaround:
- Add a destruction helper (a form that destroys fields and data)
- Link to it in configuration
- Mention it in module description so the text shows up in the module list: 'For uninstall go to configuration and hit "Prepare uninstall'".
Comment #4
mbovan CreditAttribution: mbovan at MD Systems GmbH commentedImplemented suggestions above and added tests.
The screenshot:
Comment #5
mbovan CreditAttribution: mbovan at MD Systems GmbH commentedProbably we don't need to inherit from
ConfigFormBase
.Comment #6
BerdirThanks, good start.
We can't hardcode a link like this, it won't work if you install in a Submodule. I'd just add a description like Configuration > Web services > Simplenews > Settings.
We don't need to delete nodes, just our field.
This is config, this should be deleted automatically.
That's a pretty complicated way to do it :)
$field_config_storage->delete($simplenews_fields) should the same.
both variables should use fieldS not field.
the count is the amount of rows to delete, not fields. As discussed, you need to do this in a loop until that loadByProperties() at the beginning of that function, which you need to duplicate returns no results. A do while loop should work well for this.
I'm not sure if we should convert this into a batch already here, it probably would make sense because otherwise we'll likely not do it and then it will explode for people with a few hundred subscribers.
Use mass-subscribe, generate 10k unique emails (php for loop, example-$i@example.org). Then try to hit that button.
Or locally, try generating 1k or 10 of them in here ;)
Comment #7
mbovan CreditAttribution: mbovan at MD Systems GmbH commentedMade the changes above...
Not sure if we should handle the case when user after "Prepare uninstall" wants to access (e.g.) Newsletter issues...
Comment #9
BerdirNice, tested manually, works quite well.
Opened #2594223: Mass subscribe is way slower than it was in 7.x.