ERRORs after module uninstall

Created on 27 January 2024, 10 months ago
Updated 5 March 2024, 9 months ago

When removing the module (Uninstall) it doesn't delete the fields it created during installation.
As rersult the system crashed.
==
Drupal\Component\Plugin\Exception\PluginNotFoundException: The "maximum_order_quantity" plugin does not exist. Valid plugin IDs for Drupal\commerce\EntityTraitManager are: in Drupal\Core\Plugin\DefaultPluginManager->doGetDefinition() (line 53 of /.../core/lib/Drupal/Component/Plugin/Discovery/DiscoveryTrait.php).

🐛 Bug report
Status

Active

Version

1.0

Component

Code

Created by

🇬🇧United Kingdom londova

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @londova
  • 🇨🇿Czech Republic czeky

    Hi, same here, needed to reinstall whole system.

  • Same problem. Once you uninstall, and you visit the variation page where the trait was turned on, you get this error.

    [The first time I tried it, it actally came up but the trait was still shown with the value grayed out, even though the module was no longer there. Second time I installed/uninstalled got this error. ]

    I tried
    - drush cache clear,
    - truncating the DB table "cache_recovery" (this is rebuilt after cache_clear),
    but problem still exists.

    This commerce module had a similar problem, and somebody wrote a long hook_uninstall patch, that checks and clears the traits.
    https://www.drupal.org/files/issues/2906694-uninstall-traits-5.patch
    I have not tried doing something like this, but this module may need something similar.

    For us, we decided not to install this module on production, but write a custom solution.

  • I found a temporary workaround, until this is fixed for real.

    The trait is recorded in the config for the product_variation (but never flushed upon uninstall)
    The steps are:
    1) export single config (for example using the config-export interface)
    2) edit it,
    3) re-import it.

    Here is the config for the product_variation that has the trait, this is left after uninstall:
    traits:
    - maximum_order_quantity
    ...
    .... [ it may have more, depending how you configured it, in our case we only had maximum ]

    Here is what the line should read after you edit it, assuming there are no other traits from some other module that you need:
    traits: { }

    After the re-import the system works normally again.

    The real solution would be to flush the config upon uninstall in hook_uninstall

Production build 0.71.5 2024