Update path from 2.3 to 3.3 fails due to wrong hook_update_N number

Created on 21 November 2024, 28 days ago

As reported by @scotwith1t, the upgrade seems to go wrong because there are no upgrades once you switch to v3. This is because I cherry-picked an update hook from v3 to v2 without changing the number. Silly me.

Let's fix this ASAP.

🐛 Bug report
Status

Active

Version

3.3

Component

Code

Created by

🇧🇪Belgium kristiaanvandeneynde Antwerp, Belgium

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

Comments & Activities

  • Issue created by @kristiaanvandeneynde
  • 🇺🇸United States scotwith1t Birmingham, AL
  • 🇧🇪Belgium kristiaanvandeneynde Antwerp, Belgium
  • 🇧🇪Belgium kristiaanvandeneynde Antwerp, Belgium

    Will cut a release and recommend people affected by this bug run:

    drush php-eval \Drupal::service('update.update_hook_registry')->setInstalledVersion('group', 9211);
    
  • 🇧🇪Belgium yazzbe

    In shell (bash) I had to include parentheses.

    drush php-eval "\Drupal::service('update.update_hook_registry')->setInstalledVersion('group', 9211);"
    
  • 🇧🇪Belgium kristiaanvandeneynde Antwerp, Belgium

    Updated the release notes

  • 🇧🇷Brazil aluzzardi Pelotas, RS

    Are you sure that this only happens from 2.3 to 3.3?
    I have this message when upgrading from 3.2.2 to 3.3.1:

     [error]  The installed version of the /Group/ module is too old to update. Update to
    an intermediate version first (last removed version: 9211, installed version:
    9210).

    And then the upgrades runs:

     -------- ----------- --------------- --------------------------------------------------------------
      Module   Update ID   Type            Description
     -------- ----------- --------------- --------------------------------------------------------------
      gnode    8007        hook_update_n   8007 - Updates views to drop obsolete key.
      group    10300       hook_update_n   10300 - Updates database and fields from Group 2 to Group 3.
      group    10301       hook_update_n   10301 - Updates indexes from Group 2 to Group 3.
      group    10302       hook_update_n   10302 - Updates views from Group 2 to Group 3.
      group    10303       hook_update_n   10303 - Updates views to drop obsolete key.
     -------- ----------- --------------- --------------------------------------------------------------

    Those should be running even coming from 3.2 installations?

  • 🇧🇪Belgium kristiaanvandeneynde Antwerp, Belgium

    Dammit you're right I shouldn't have upped that number in 3.3.x.

    Will hotfix release in the morning. This mess is coming from the fact that we have two versions being kept in sync but with different update hook numbers :/

  • 🇺🇸United States scotwith1t Birmingham, AL

    I suppose the good news is that the update hooks, if a user resets the schema version via drush and runs them a second time, should probably not find anything to update anyway. 🤷‍♂️ Thanks for your work on this as always Kristiaan.

  • 🇨🇦Canada nickdjm

    Trying the update out after I reset the installed version to 9211 and I get the following error:

    >  [notice] Update started: group_update_10300
    >  [error]  The "entity:group_content" plugin does not exist. Valid plugin IDs for Drupal\search_api\Datasource\DatasourcePluginManager are: entity:block_content, entity:comment, entity:consumer, entity:contact_message, entity:content_moderation_state, entity:crop, entity:file, entity:flagging, entity:group_config_wrapper, entity:group, entity:group_relationship, entity:media, entity:node, entity:path_alias, entity:profile, entity:redirect, entity:search_api_task, entity:shortcut, entity:taxonomy_term, entity:user, entity:webform_submission, entity:menu_link_content, entity:paragraph, solr_document, solr_multisite_document 
    >  [error]  Update failed: group_update_10300

    The only place I see reference to 'group_content' is in my config. All custom and contrib code has been updated appropriately. Should I be updating the config before I try to run the updates? Or should the updates be taking care of that?

  • 🇺🇸United States tyler.hastain Utah

    It appears that comment #7 solved the problem for us.

  • 🇧🇪Belgium kristiaanvandeneynde Antwerp, Belgium

    https://www.drupal.org/project/group/releases/3.3.2

    Also re #12, it seems like some search_api code is running before Group has had a chance to fully convert group_content to group_relationship.

  • 🇫🇮Finland kekkis Pirkkala

    The group_update_9211 function is now defined twice in group.install in version 2.3.1. I'll create a follow-up.

  • 🇫🇮Finland kekkis Pirkkala

    Added the issue I encountered as a related issue although I recognized it's not actually an issue with this change, rather with another MR sharing the hook ID.

  • 🇨🇦Canada nickdjm

    Re #15 ah yeah, only way we're finding around it is disabling search_api entirely, otherwise it just fails. I'll see if I can find a solution that does not involve uninstalling the module and if it's something group-related I'll open an issue/MR.

  • 🇧🇷Brazil aluzzardi Pelotas, RS

    #10 I did not see the error anymore about the installed version being too old.
    But I still see the database updates running after the upgrade from 3.2.2 to 3.3.2
    Is that the expected behavior if I'm not upgrading from version 2.x?
    My feeling is that upgrades, if needed to run, should check an show a notice/information that they are not running as the current version is already version 3.x

  • 🇧🇪Belgium kristiaanvandeneynde Antwerp, Belgium

    Hooks group_update_10300 through group_update_10302 run but don't do anything if you were already on v3. Hook group_update_10303 needs to run no matter what version you came from.

  • 🇧🇷Brazil aluzzardi Pelotas, RS

    kristiaanvandeneynde Thanks for explaining!

  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.71.5 2024