According to the documentation, when updating from a D6 version of a module to D7, the update system should run all updates in 70** but NOT 71**. However, it appears that updates in the 71** branch are getting called. This is a big problem that we've run into in two modules- see the bulk of the discussion in the Background Process issue (#1426120: Error on upgrade from 6.x to 7.x), and the original Mailhandler issue (#1393040: Upgrade path from 6.x to 7.x-2.x).

I'm marking it as major because it completely breaks the D6 -> D7 upgrade path for certain modules, and there's really no sensible workaround.

Comments

catch’s picture

Status: Active » Postponed (maintainer needs more info)

According to the documentation, when updating from a D6 version of a module to D7, the update system should run all updates in 70** but NOT 71**.

I'm not aware of any documentation that states this, could you point to it?

danepowell’s picture

Status: Postponed (maintainer needs more info) » Active

Okay, upon closer inspection of the documentation for hook_update_n()...

Users can directly update from 5.x-2.* to 6.x-2.* and they get all 60XX and 62XX updates

However, this doesn't sound like a very good policy. In quite a few (most?) modules, the 6.x and 7.x branches are being developed simultaneously, meaning that many of the schema updates will be redundant between the branches. In other words, hook_update_6101 is likely to be identical to hook_update_7101, etc... So when users upgrade from 6.x to 7.x, they are getting a ton of redundant schema updates that break the upgrade process.

It seems fairly obvious to gielfeldt and me that the way this was probably intended to work (and is implied, though not stated explicitly, elsewhere in the docs) is that upgrading from 6.x to 7.x should ONLY run 70XX updates. This is supported by the fact that the docs refer to an outdated version of Drupal, and there has been traction in related issues (#1167996: UPGRADE.txt needs to say all D6 contrib modules need to be upgraded to their latest D6 versions before the D6->D7 update) since then.

marcingy’s picture

Priority: Major » Normal

This is not major it isn't even really a bug to be honest

catch’s picture

Category: bug » support

No this is by design, which is why I asked for a pointer to the documentation to see if it was documented incorrectly.

webchick’s picture

Category: support » bug
Status: Active » Closed (works as designed)

Yeah, I don't understand. This is working exactly as designed. The update numbering scheme is purely a convenience for module developers to keep track of when update functions were introduced.

webchick’s picture

Category: bug » support
danepowell’s picture

Status: Closed (works as designed) » Active

Okay, if this is 'by design' then I guess this is a support request or feature request. But my original problem (described in the linked issues and in #2) still stands: how is a maintainer supposed to maintain 6.x and 7.x branches simultaneously, and allow 6.x -> 7.x upgrades? Again, the problem is that many of the schema updates are duplicated between the 6.x and 7.x branches, meaning that upgrades from 6.x-7.x fail.

As an example, let's say you have these hooks:

<?php
// Obviously this is pseudocode
function hook_update_6101() {
  db_add_field('new_field');
}

function hook_update_7001() {
  db_add_field('d7_field');
}

function hook_update_7101() {
  db_add_field('new_field');
}
?>

Perfectly reasonable, and yet upgrades from 6.x-7.x will fail because new_field already exists. This is a somewhat trivial example and is easy to guard against, but there are cases where it's much more difficult to guard against this. Assuming that the user is coming from the latest 6.x schema (a good assumption since #1167996: UPGRADE.txt needs to say all D6 contrib modules need to be upgraded to their latest D6 versions before the D6->D7 update) then only hook_update_7001 should be called on upgrade to convert to the latest 7.x schema.

gielfeldt’s picture

Perhaps another way to ask is: What is the reason/usecase for running hook_update_71xx on D6->D7 upgrade? It seems to be more of an obstacle than a help. Would it be a good idea to revisit this design?

danepowell’s picture

Can someone besides gielfeldt and myself at least acknowledge that there's a problem here?

I don't want to mark this as 'major' again just to get attention, but I'm not sure what else to do. Keep in mind that it prevents upgrades to Drupal 7.x for at least least two projects and 3,000 users, and the problem will only grow if it isn't tackled early.

catch’s picture

No it really is by design, your module needs to work around it if you have conflicting updates bewteen 7.x-1.x and 7.x-2.x branches.

For the example in #7, you could remove the 70* updates from the 7.x-1.x branch altogether, or you can use db_field_exists() to check if a column exists before trying to add it.

gielfeldt’s picture

Alright, this is by design. Then I ask, what is the reason for this design, and would it be a good idea to revisit this in order to improve this? Does our suggestion limit the current functionality in any way, or will it in fact just make it easier to create upgrade paths for modules?

IMO running db_field_exists() etc, is somewhat cumbersome and perhaps unnecessary if we change the design.

I'm thinking that we just avoid running 71xx updates on D6 => D7 upgrade. Will that limit the feature set of the install hooks in any way?

Thoughts?

danepowell’s picture

Thank you for clarifying, catch. I agree with gielfeldt that we should reconsider whether this is the best design, considering how much extra burden it places on maintainers and in many cases will prevent users from upgrading to later versions of Drupal.

gielfeldt’s picture

Category: support » feature

This ticket now seems more to fit the category feature request.

gielfeldt’s picture

What probably is a bug, is that 7000 is run on non major upgrades.

Status: Active » Closed (outdated)

Automatically closed because Drupal 7 security and bugfix support has ended as of 5 January 2025. If the issue verifiably applies to later versions, please reopen with details and update the version.