cannot upgrade spam module from 5.x-3.0-beta1 to 6.x-1.0

anarcat - October 24, 2009 - 05:33
Project:Hosting
Version:6.x-0.4-alpha2
Component:Code
Category:bug report
Priority:critical
Assigned:Unassigned
Status:closed
Description

So this is rather weird. I'm getting an error trying to upgrade my blog from Drupal 5.17 to Drupal 6.20. I am running the spam module version 5.x-3.0-beta1 and the version on the new platform is 6.x-1.0.

Out of the box, alpha2 will refuse doing the upgrade: there will be an error marked in the platform listing. When comparing packages, it shows the spam module as only version "6" in the target column (as opposed to 6.x-1.0), and the box is red.

spam       5.x-3.0-beta1 (5305)            6

When running the comparison request by hand, we see the following in the tables:

mysql> SELECT * FROM current c LEFT JOIN target t ON c.nid=t.nid WHERE (c.schema_version > t.schema_version) OR (c.version_code > t.version_code) AND NOT ( (c.version_code < t.version_code) OR (c.schema_version < t.schema_version)) AND c.status=1;
+-----+------------+--------------+----------------+---------------+--------+------+------------+--------------+----------------+---------+--------+
| nid | short_name | version_code | schema_version | version       | status | nid  | short_name | version_code | schema_version | version | status |
+-----+------------+--------------+----------------+---------------+--------+------+------------+--------------+----------------+---------+--------+
|  54 | spam       |  50003000301 |           5305 | 5.x-3.0-beta1 |      1 |   54 | spam       |  60001000500 |              0 | 6.x-1.0 |      0 |
+-----+------------+--------------+----------------+---------------+--------+------+------------+--------------+----------------+---------+--------+

Notice the version_code is 0 for the 6.x instance.

I have a solution, but i'm a bit unsure about it so I'm uploading it for review. The first chunk fixes the display in the comparison page by priorising upgrades and the second one fixes the platform listing by making sure the target code is valid when comparing.

The patch sits in my production branch (as I needed it right away!): http://git.koumbit.net/?p=drupal/modules/hosting/.git;a=commitdiff_plain...

I'm a bit unconfortable about having different algorithms for the two functions.

Testing required.

#1

anarcat - October 24, 2009 - 06:00

#2

adrian - October 24, 2009 - 06:41

it's only checking schema versions now, and spam module had it's schema removed.

#4

adrian - October 26, 2009 - 15:22

the issue is that the module itself provides no upgrade path.

all the updates have been removed, so there is no upgrade path :
http://cvs.drupal.org/viewvc.py/drupal/contributions/modules/spam/spam.i...

we detect the schema version of the module based on which update_x functions are contained inside the .install file, so this leaves us with 2 options.

1. disable the module before doing the migration, and re-enable it.
2. consider the minimum target schema version to be the current schema version. this might open us to other errors however.

#5

adrian - October 26, 2009 - 16:45
Status:needs review» fixed

committed with slight variations.

thanks anarcat.

#6

System Message - November 9, 2009 - 16:50
Status:fixed» closed

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

 
 

Drupal is a registered trademark of Dries Buytaert.