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.
uc_payment_install() adds 'payment_received' order status on install and quite rightly does not remove it when uninstalled. If uc_payment is installed again it causes a database insert error as the order status already exists.
Comment | File | Size | Author |
---|---|---|---|
#10 | reinstall.patch | 6.4 KB | longwave |
| |||
#3 | ubercart-payment_install-2533192-3.patch | 993 bytes | tinker |
#1 | ubercart-payment_install-2533192-1.patch | 1.25 KB | tinker |
Comments
Comment #1
tinker CreditAttribution: tinker as a volunteer commentedAttached patch adds check to uc_payment_install() to see if 'payment_received' status already exists.
Comment #2
TR CreditAttribution: TR commentedCan you use db_merge() instead? See uc_paypal.install in hook_install() for how we did this with the paypal_pending order status.
Comment #3
tinker CreditAttribution: tinker as a volunteer commentedRevised patch using db_merge().
Comment #5
longwaveCommitted, thanks for the patch!
Comment #6
TR CreditAttribution: TR commentedLet's make sure we take care of this in 8.x-4.x too - we actually have more problems like this because of the config system. Configs for other modules, like uc_order.status.payment_received.yml in this case, aren't removed upon uninstall and you can't reinstall without taking care of that.
Comment #7
longwaveTrue, though I'm not sure what the correct method to handle this is in Drupal 8. For reference when you install uc_payment, uninstall it, and reinstall it again, a PreExistingConfigException is thrown with message 'Configuration objects (uc_order.status.payment_received) provided by uc_payment already exist in active configuration'.
Comment #8
TR CreditAttribution: TR commentedFor reference, this is a problem with configs for:
And of course with fields ...
Comment #9
longwaveI reproduced this in core alone with Forum module via its dependency on Comment, so I reported it as a bug over there to see what the right solution is: #2534532: Cannot reinstall Forum after it was previously installed
Comment #10
longwaveA start on this following what I learned from #2534532: Cannot reinstall Forum after it was previously installed
Comment #11
TR CreditAttribution: TR commentedFor some of the configs that seems to be the right way to go. For others, not so much.
Take for example the order status 'abandoned', which is defined by uc_cart. I would argue that the way we handle it now is pretty good. When uc_cart is uninstalled, a message is shown that says the 'abandoned' status has not been deleted and gives a link to delete it. uc_cart_uninstall() unlocks the status so it can be deleted, but it does not delete it because there may be data in the database that depends on this. (Now of course if uc_order gets uninstalled, it DOES make sense to remove any module-provided statuses at that time). Deleting in this case should be a conscious choice of the administrator, not something that is done automatically. Perhaps we can follow in the footsteps of the image module where, when you delete an image style, if someone is using it you are given the choice to replace current uses with a different style. That would be nice for other order statuses too.
The big problem we have that could be fixed with enforced dependencies is re-installing content types like Product Kits - that is directly analogous to the Forum situation. In that case, it makes perfect sense to remove the node type configuration from the database.