Update hook Sequence

I’m looking for guidance (and possibly documentation examples) on the recommended core/contrib‑safe way to update hooks sequence.

So, I have some hooks number which is already ran and those already ran number was not correct so I am writing post update hook which will reset my hook number to 10013\Drupal::service('update.update_hook_registry')->setInstalledVersion('module_name', 10013) so now the next hook which would run is 10014,So, I want to add hook_10014 which should throw an exception, is there any safe way like core is doing something like this?

Example:

already ran hook was 100013 which is a wrong number because after 10009 correct number ishook_10010, hook_10011, hook_10012, hook_10013 and so on... so I am fixing those numbers by resetting hooks schema. Is there any way in Drupal core where we are fixing this type of problem.

Comments

anmol singh created an issue. See original summary.

anmol singh’s picture

Issue summary: View changes
quietone’s picture

Priority: Major » Normal

I only have a minute. Have you read the function hook_update_N API documentation?

Some text from that document

what matters is that you must ALWAYS increase the number when a new update hook is added

Never renumber update functions. The numeric part of the hook implementation function is stored in the database to keep track of which updates have run, so it is important to maintain this information consistently.

Support requests are always 'normal' priority.
And keep in mind that the Drupal Core issue queue is not the ideal place for support requests. The 'support request' option is there for filing support issues for contributed modules and themes. There are several support options listed on our Support page, including the Drupal Forums and Drupal Answers. There is also Drupal Slack. You may get better replies in one of those places.

quietone’s picture

Status: Active » Fixed

The Drupal Core issue queue is not the ideal place for support requests. The 'support request' option is there for filing support issues for contributed modules and themes. There are several support options listed on our Support page, including the Drupal Forums and Drupal Answers. There is also Drupal Slack. You may get better replies in one of those places.

I am closing this per the guidance in Handle or refer a support request in an issue.

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

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