2

On hook_update_N() the documentation says:

mymodule_update_7000(): This is the required update for mymodule to run with Drupal core API 7.x when upgrading from Drupal core API 6.x.

mymodule_update_7200(): This is the first update to get the database ready to run mymodule 7.x-2.. Users can directly update from 6.x-2. to 7.x-2.* and they get all 70xx and 72xx updates, but not 71xx updates, because those reside in the 7.x-1.x branch only.

Is it really mandatory to define an 7000 update hook? I saw some contributed module updates that starts with 7300, when the module version for Drupal 7 is 7.x-3.x.

I am a bit confused, because I read before the UPGRADE.txt file for Drupal 7 core that says:

MAJOR VERSION UPGRADE
To upgrade from a previous major version of Drupal to Drupal 7.x, after following the instructions in the INTRODUCTION section at the top of this file:

  1. In addition to updating to the latest available version of Drupal 6.x core, you must also upgrade all of your contributed modules for Drupal to their latest Drupal 6.x versions.

For me, it means that users can't directly update from 6.x-2.x to 7.x-2.x unless 6.x-2.x module was the latest in the Drupal 6.x versions. Is this correct?

What about eventual database updates defined by 7.x-1.x branch? Do they have to be reported in the 70xx updates?

Can a module version 7.2.x keep any other updates (e.g. 60xx, 71xx) or it should be clean and defined only updates about 70xx and 72xx?

  • It seems that as you are asking multiple questions, it will be difficult to answer. Is there a specific real-world question you are asking? – cilefen Jan 4 '16 at 0:01
  • I can spread it into multiple issues questions related. But I'm not sure that it is the best way because all sub questions are in fact related to a same global issue (N version in hook_update_N) – ostry.sn Jan 4 '16 at 17:59
  • Perhaps retitle something like "Explain the N-rules in hook_update_N". – cilefen Jan 4 '16 at 18:18
  • As far as I recall, what described there was planned, but the actual code just executes any update that has not been yet executed, without making any difference between 71xx and 72xx. I cannot find anything in the code that checks if the installed module was 6.2.x, or 6.1.x. – kiamlaluno Jan 4 '16 at 20:55
2

Basing on the documentation, 70xx updates are only necessary if there are updates from Drupal 6.x to Drupal 7.x that are necessary for any branch the Drupal 7 module has (e.g. 7.x-1.x, 7.x-2.x, 7.x-3.x). If that is not the case, then you don't need to use 70xx as update numbers.

As said in the documentation, updates numbered 72xx allows updating from the 6.x-2-x version of the module to the 7.x-2.x version, but not from the 6.x-3.x version. This is generally not a problem, since project maintainers normally create a version 7.x-3.x together a version 6.x-3.x.

As the documentation reports, updates numbered 71xx are for updated from version 6.x-1.x to 7.x-1.x; updates numbered 70xx are for updates from Drupal 6 to any branch of the module for Drupal 7.x. You don't copy the 70xx updates in 71xx updates, since those are already executed for the 7.x-1.x branch.

As for the updates to keep, the documentation says:

A good rule of thumb is to remove updates older than two major releases of Drupal.

So, updates for a 7.x-1.x version should still be kept for a 7.x-2.x version.

Keep in mind that, as far as I recall, what described in the documentation about which updates are run when updating from Drupal 6 to Drupal 7 doesn't describe what the code actually does. For what I recall, Drupal code simply run any updates higher than the last executed update. For example, if a module last time ran its 6123 update, Drupal will run any update higher than that number, such as 7000, 7100, and 7200, if they are defined.

  • a)I am confused when you say about this topic that what described in the documentation doesn't describe what the code actually does. This is a little bit worrying! Otherwise, ok I understand now that in theory, for e.g 73xx was planned to be executed only for the 7.x-3.x branch (either for an updating from the 6.x-3.x branch or from previous 7.x branches, regardless). And in case of updating from the 6.x-3.x branch, we should in theory use 7000 update, in addition. – ostry.sn Jan 5 '16 at 13:50
  • b) When you say: "You don't copy the 70xx updates in 71xx updates, since those are already executed for the 7.x-1.x branch." You meant "..in 72xx updates" ? – ostry.sn Jan 5 '16 at 13:51
  • c) Documentation says : "A good rule of thumb is to remove updates older than two major releases of Drupal." Is it an error when they say two major releases of Drupal ? They meant two module's major release version ? – ostry.sn Jan 5 '16 at 13:51

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.