Establish uninstall hook for undoing group_content_menu_update_9000()

Created on 16 January 2023, almost 2 years ago
Updated 3 October 2023, about 1 year ago

Problem/Motivation

A team member updated us from 1.1 to the latest dev version. It didn't work for our needs so we rolled back to 1.1 Now on every group add, we get the error:

Drupal\Core\Entity\EntityStorageException: The "field_item:menu_link_reference" plugin does not exist.

menu_link_reference does not exist anywhere in our codebase including our config.

In general this module should have an uninstall hook for this plugin definition, which is code I could borrow and run to undo this plugin definiton anyways I presume?

Trying to grok through this all right now. If anyone else has this issue at least now there's something out there with the error listed to reference and discuss.

🐛 Bug report
Status

Active

Version

1.0

Component

Code

Created by

🇺🇸United States jnicola

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

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • heddn Nicaragua

    That sub module and logic was only ever released in a dev branch. We have since removed that sub module.

  • Status changed to Closed: won't fix almost 2 years ago
  • heddn Nicaragua

    I _think_ this can be cosed/wont-fix. But if someone disagrees, feel free to re-open.

  • 🇫🇮Finland thatguy

    I have an issue with the submodule menu_link_reference being removed in the 3.0.x branch. I understand that the dev-versions can have this kind of things happening and we shouldn't use them but at the moment there isn't other way to do it with Group v3.

    So I tried to update to the latest dev-commit but I received error for the missing menu_link_reference module. I manually removed the dependency to the menu_link_reference submodule, then uninstalled it and updated group_content_menu to the latest dev-commit. Now I receive error "Drupal\Core\Entity\EntityStorageException: The "field_item:menu_link_reference" plugin does not exist.".

    Any ideas what I could do without breaking the existing group content menus?

  • Status changed to Active almost 2 years ago
  • heddn Nicaragua

    Let's add a post update that removes the field:

      $entity_definition_update_manager = \Drupal::entityDefinitionUpdateManager();
      if ($entity_definition_update_manager->getEntityType('group_content_menu') !== NULL) {
        $storage_definition = $entity_definition_update_manager->getFieldStorageDefinition('parent', 'group_content_menu');
        if ($storage_definition !== NULL) {
          $entity_definition_update_manager->uninstallFieldStorageDefinition($storage_definition);
        }
      }
    
  • Status changed to Closed: won't fix almost 2 years ago
  • 🇫🇮Finland thatguy

    Thanks @heddn that seems to fix the issue, although the problem is that I have to run it before updating to the latest dev-commit :D If there is other way to solve that would be nice but I can work with this I think.

    Here are my steps that I needed to do, they are more complicated since these had to be done through deployments to couple of environments:

    1. Create a patch with the post update hook posted by heddn at #5 and also include removal of dependency to menu_link_reference in group_content_menu.info.yml

    2. Run patches but avoid updating module. Run update hook, uninstall menu_link_reference

    3. Remove unneeded patches, update module

  • Status changed to Active almost 2 years ago
  • 🇫🇮Finland thatguy

    Oops didnt mean to change the status

  • heddn Nicaragua

    Oops, I also had to re-add a dummy plugin too.

    /**
     * Defines the 'menu_link_reference' field type.
     *
     * @FieldType(
     *   id = "menu_link_reference",
     *   label = @Translation("Menu link reference"),
     *   category = @Translation("General"),
     *   default_widget = "menu_link_reference",
     *   default_formatter = "string",
     *   no_ui = TRUE,
     * )
     */
    final class MenuLinkReferenceItem extends FieldItemBase {}
    
  • 🇨🇭Switzerland phma Basel, CH

    It seems to get worse if you have data in the field. I'm not sure where the constraint comes from, because either of these can be NULL.

    [error]  SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'parent_id' cannot be null: INSERT INTO "field_deleted_data_d0a1ee0c5e" ("bund
    le", "entity_id", "revision_id", "langcode", "parent_menu_name", "parent_id", "deleted", "delta") SELECT "entity_table"."bundle" AS "bundle", "entity_t
    able"."id" AS "entity_id", "entity_table"."id" AS "revision_id", "entity_table"."langcode" AS "langcode", "entity_table"."parent__menu_name" AS "parent
    _menu_name", "entity_table"."parent__id" AS "parent_id", :deleted AS "deleted", :delta AS "delta"
    > FROM
    > "group_content_menu_field_data" "entity_table"
    > WHERE ("entity_table"."parent__menu_name" IS NOT NULL) OR ("entity_table"."parent__id" IS NOT NULL) FOR UPDATE; Array
    > (
    >     [:deleted] => 1
    >     [:delta] => 0
    > )
    
  • 🇺🇸United States jnicola

    Okay, I believe this patch does the trick. It combines the post_update hook and the fake plugins.

    What it does not do, and I have not tested yet, is the bit phma mentions when there is content in the field already. I'll write another patch for that if necessary.

Production build 0.71.5 2024