Problem/Motivation
When a module defines a custom FieldType plugin (for example, custom_field_type) and this FieldType storage is implemented in a field.storage YAML file (for example in field.storage.commerce_product.custom_field.yml), the module cannot be uninstalled anymore because the error The %field_type_label field type is used in the following field: @fields is triggered by Drupal\field\FieldUninstallValidator.
This is logical behavior because normally the FieldType plugin should not be removed as long as implementations exist. However, in some scenarios removal of the plugin should also trigger removal of dependent implementations. This would be the case for example when the FieldType storage implementation YAML exists in the same module as the FieldType plugin.
Proposed resolution
Do not abort the uninstall procedure in Drupal\field\FieldUninstallValidator if the module that is being removed contains the FieldType plugin when it is defined as an enforced module dependency in the FieldType storage implementation that would otherwise trigger the abortion.
Remaining tasks
Does the patch still apply?
Review
Commit
API changes
Any field storage definition that needs to be deleted should include the module name (example_module) that defines the FieldType plugin an enforced module dependency with the following YAML code:
dependencies:
module:
- example_module
enforced:
module:
- example_module
| Comment | File | Size | Author |
|---|---|---|---|
| #52 | 2871486-52.patch | 5.4 KB | jmagunia |
| #49 | 2871486-nr-bot.txt | 154 bytes | needs-review-queue-bot |
| #41 | interdiff-2871486-39-41.txt | 795 bytes | mohit_aghera |
| #41 | test-only-2871486-41.patch | 5.4 KB | mohit_aghera |
| #41 | 2871486-41.patch | 7.38 KB | mohit_aghera |
Comments
Comment #2
Plankje commentedComment #3
Plankje commentedComment #4
Plankje commentedFixed file name of patch
Comment #8
joachim commentedGood catch!
> Any field storage definition that needs to be deleted should include the module name (example_module) that defines the FieldType plugin an enforced module dependency with the following YAML code:
I don't think that's a good API change. Automatic config dependency calculation is very useful, and we shouldn't be removing part of it.
Comment #9
jsacksick commentedComment #10
jsacksick commentedThe Commerce Recurring module is affected by this bug (See #2924965: [PP-1] Module does not uninstall cleanly (dependency issue)). It cannot be uninstalled because of this bug...
Comment #12
handkerchiefAny news on this?
Comment #13
thronedigital commentedWould be curious as well where we are at with this?
Comment #14
dscl commentedUnassigning the issue given that Plankje is clearly not working on that anymore.
This may lead it to be picked up by other contributor.
Comment #16
thronedigital commentedUpdate please.
Comment #17
dercheffeAny news about this issue?
Comment #18
aleevasTrying to reroll for last versions.
Comment #19
dercheffeIf the patches are rerolled they need to reviewed or am I wrong? So changing issue status.
Comment #20
aleevas@dercheffe
you're absolutely right.
Thank you!
Comment #22
jmoruziAny news/updates about this?
Comment #24
xamountI'm willing to pay USD$25 to get this bug squashed and committed to core. Any takers?
Comment #25
joachim commentedThe variable name should be in snake_case.
This logic needs a comment to explain what's being done.
Comment #26
xamountI have tested the patch #18 and it fixed this issue.
I have also made the changes you suggested and attached a new patch. Please review.
Comment #27
xamountComment #28
anmolgoyal74 commentedLooks like xamount has uploaded the interdiff as patch.
Comment #29
xamountahh my bad, good catch! sorry about that.
Comment #30
zenimagine commentedHi, has anyone successfully uninstalled "Commerce Recurring Framework" ?
Comment #31
xamount@zenimagine Yes I have. Here are the steps:
Step 1: Apply the patch from this issue queue
Step 2: In the commerce_recurring module (8.x) inside of config/install you have to update ALL the field.storage... yml files to the API changes suggested at the top of this page.
For e.g. in commerce_recurring/config/install/field.storage.commerce_order.billing_period.yml
before:
after:
Step 3: After you have updated all the field.storage yml files inside of config/install then you need to reimport the config with a command such as
drush cim -y --partial --source=modules/contrib/commerce_recurring/config/install;Step 4: clear cache
Step 5: Then try to uninstall commerce_recurring
I confirm that this has worked for me. If someone can review the latest patch in this issue queue and we can get it committed into core, I will gladly write the patch for #2924965: [PP-1] Module does not uninstall cleanly (dependency issue)
Comment #32
zenimagine commentedThanks for the explanations, I will wait for a patch because it seems very complicated. It's been 2 years since I made the mistake of installing this module on my production site and could not uninstall it. I can't wait to get rid of it.
Comment #33
xamountI am going to set the status to RTBC. Feel free to change it back to "Needs Review".
Comment #34
jungleNeeds tests or I am afraid that it won't be committed.
Comment #35
jungleComment #36
colanSee #10.
Comment #37
nattyweb commentedxamount's advice in #34 looked promising for me after following the instructions carefully. Until, that is, I reached step 4, at which point I got this after issuing the drush cache:rebuild (and also the error "the website encountered an unexpected error. Please try again later." on the site):
So I guess it's not possible, unless I did something wrong (or have a peculiar setup).
Comment #39
mohit_aghera commentedAdding test cases with simple entity and field plugin.
For the testing i've included configuration which has "enforced" key in it.
Comment #41
mohit_aghera commentedFixing test case failures related to the field storage configuration yml file.
I've updated test-only file as well.
Comment #43
mohit_aghera commentedComment #46
rivimeyBump:
Given this affects commerce_recurring directly, and there is a patch is there any scope for a resolution to this soon?
Comment #47
quietone commentedThis was a Bug Smash random triage issue. I was wondering if this was works as designed but darvanen disagreed. Updated the remaining tasks to indicate this Needs review.
Comment #49
needs-review-queue-bot commentedThe Needs Review Queue Bot tested this issue. It either no longer applies to Drupal core, or fails the Drupal core commit checks. Therefore, this issue status is now "Needs work".
Apart from a re-roll or rebase, this issue may need more work to address feedback in the issue or MR comments. To progress an issue, incorporate this feedback as part of the process of updating the issue. This helps other contributors to know what is outstanding.
Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.
Comment #50
joshuautley commented@rivimey #46 following up on this as it relates to commerce_recurring.
Has anyone used the patch in #41 successfully in this use case?
Comment #52
jmaguniaEven after the patch in #41 Commerce Recurring fails upon uninstall for me:
commerce_recurring: The <em class="placeholder">Billing period</em> field type is used in the following fields: commerce_order.billing_period, commerce_order_item.billing_periodI haven't had much luck uninstalling Commerce Core either.