Allow altering the post_update run order

Created on 20 April 2020, over 5 years ago
Updated 5 September 2025, 2 months ago

Problem/Motivation

Currently all the post_update methods are run on alphabetical order (see UpdateRegistry::getAvailableUpdateFunctions).
The documentation suggests adding numerical prefix the update names or making them completely numerical in order to control the order of execution. However, this does not take into account that post_update methods can come from different components which makes controlling the order harder.

In contrast, update methods can define requirements to one another which ensures that the order in which they run is consistent.

Proposed resolution

We could either implement a more complex requirement based solution for post_updates (like we do with updates) or we could add an alter hook that allows to alter the final order of execution.

✨ Feature request
Status

Needs work

Version

11.0 πŸ”₯

Component
Database updateΒ  β†’

Last updated 2 months ago

No maintainer
Created by

πŸ‡¬πŸ‡§United Kingdom ieguskiza

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

Merge Requests

Comments & Activities

Not all content is available!

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

  • The Needs Review Queue Bot β†’ tested this issue. It either no longer applies to Drupal core, or fails the Drupal core commit checks. Therefore, this issue status is now "Needs work".

    Apart from a re-roll or rebase, this issue may need more work to address feedback in the issue or MR comments. To progress an issue, incorporate this feedback as part of the process of updating the issue. This helps other contributors to know what is outstanding.

    Consult the Drupal Contributor Guide β†’ to find step-by-step guides for working with issues.

  • First commit to issue fork.
  • πŸ‡§πŸ‡ͺBelgium joevagyok

    Rerolled over 11.x.

  • Pipeline finished with Failed
    2 months ago
    Total: 154s
    #590951
  • πŸ‡§πŸ‡ͺBelgium joevagyok

    Patch for 10.5.x version of core.

  • πŸ‡ΊπŸ‡ΈUnited States nicxvan

    I'll be honest, I have strong reservations about this.

    We do have a way to order them already just by numbering them.

    This looks suspiciously like hook module implements alter that was a monumental effort to replace.

    Can we get a description of the scenarios where ordering is necessary here and why alpha numeric isn't sufficient?

    I'd also want to review hook update dependencies in depth to see if that can be applied.

  • πŸ‡§πŸ‡ͺBelgium joevagyok

    In the patch made for 10.5.x in comment #27 I realized that one function call is missing and the feature doesn't work as expected. Uploading the correct patch.

  • Pipeline finished with Failed
    2 months ago
    Total: 305s
    #591589
  • πŸ‡§πŸ‡ͺBelgium joevagyok

    @nicxvan Our use case that requires this is the following:
    We have an install profile and we need to make sure, that all dependent components/modules run their post_update functions before the install profile post updates, hence why the existing solutions are not enough, like it is described in the issue description.

  • Pipeline finished with Failed
    2 months ago
    Total: 161s
    #592789
  • πŸ‡§πŸ‡ͺBelgium joevagyok

    Fixed the patch for 10.5.x.

  • πŸ‡§πŸ‡ͺBelgium joevagyok

    Added the missing part in the 10.5.x patch.

        public function getPendingUpdateFunctions() { ...
        return $this->alterAvailableUpdateFunctions($not_executed_update_functions);
    
Production build 0.71.5 2024