1

The documentation for hook_update_N() says the following:

Implementations of hook_update_N() are named (module name)update(number). The numbers are composed of three parts:

  • 1 digit for Drupal core compatibility.
  • 1 digit for your module's major release version (e.g., is this the 7.x-1.* (1) or 7.x-2.* (2) series of your module?). This digit should be 0 for initial porting of your module to a new Drupal core API.
  • 2 digits for sequential counting, starting with 00.

These are hypothetical questions:

What happens if you get to something like 7299? Are you required to release a major version update next even if you don't implement the hook, or if you do?

What happens if you have a lot of branches or major releases and get to something like 8900 and want to release a new one for that version of Drupal... 8(10)00? I know some modules go from 7.x-3.x to 8.x-4.x, so this could potentially happen if they continue in that way.

  • It's just a number, really, a convention; it isn't validated against the current version of the module or anything. The digit count also isn't enforced (foo_update_8101000 is valid, for example), but it's easy to introduce ambiguity if you go to extremes. Take 811123. Is that major version 11 and minor 123, or major version 1 and minor 1123? – Clive Sep 23 at 18:27
  • So in the event of the ambiguity, would it still be invoked correctly? I don't know where the hooks are invoked from. – mbomb007 Sep 23 at 18:39
  • Yep it'll be invoked, first time (so for version 1.1123 in the above example), but then if/when you get to version 11.123, the function name would be the same, so you can't use it again. You could skip a version, 11.124, but then you may have already had a 1.1124, and so on. Quite messy, and that's just one example of the, I'm sure many, possible collisions. In short, unless I'm missing something, it doesn't seem to be a system that supports what you're proposing very well – Clive Sep 23 at 18:55
  • So it just concatenates {major}{minor} and invokes if it hasn't been invoked yet? Also, you could probably write an answer. – mbomb007 Sep 23 at 19:05
  • 1
    See update_get_update_list() and drupal_get_schema_versions() for the nitty-gritty – Clive Sep 23 at 19:29
0

The one time I dealt with this, I just kept on going. After 7199, I moved to 71100, then 71101 etc. It wasn't a problem (Drupal 7).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.