Old databases might have a small {system}.weight

Damien Tournoud - October 11, 2009 - 18:38
Project:Drupal
Version:7.x-dev
Component:base system
Category:bug report
Priority:critical
Assigned:Unassigned
Status:closed
Issue tags:D7 upgrade path, Novice
Description

Some databases that came from old Drupal installations seem to have a small {system}.weight. For example, on Drupal.org:

weight tinyint(3) unsigned

This breaks the upgrade process from Drupal 6 to Drupal 7 where we bump some modules to a weight > 1000.

#2

mikey_p - October 16, 2009 - 19:57

tagging

#3

sun.core - January 26, 2010 - 17:46
Issue tags:+Novice

.

#4

ctmattice1 - January 27, 2010 - 16:06
Status:active» needs review

Ideally what should be done is to convert the 6.x system field values to match those of D7. What reason would there be on an upgrade not to do this. This will not break any 6.x sites doing this in case the update fails down stream.

Please review the following code, it does not use $schema as the table only need modification. I'm wonder though why D7 carries a int 11 in weights this seems a little high and would probably make more sense to use a small init 6 as in the schema_version field.

Index: includes/update.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/update.inc,v
retrieving revision 1.31
diff -u -p -r1.31 update.inc
--- includes/update.inc 25 Jan 2010 10:38:34 -0000 1.31
+++ includes/update.inc 27 Jan 2010 00:45:47 -0000
@@ -266,6 +266,19 @@ function update_fix_d7_requirements() {
file_put_contents(conf_path() . '/settings.php', "\n" . '$databases = ' . var_export($databases, TRUE) . ";\n\$drupal_hash_salt = '$salt';", FILE_APPEND);
}
if (drupal_get_installed_schema_version('system') < 7000 && !variable_get('update_d7_requirements', FALSE)) {
+ // Change 6.x system table field values to 7.x equivelent
+ db_change_field('system', 'status', 'status',
+ array('type' => 'int', 'length' => 11, 'not null' => TRUE, 'default' => 0));
+ db_change_field('system', 'bootstrap', 'bootstrap',
+ array('type' => 'int', 'length' => 11, 'not null' => TRUE, 'default' => 0));
+ db_change_field('system', 'weight', 'weight',
+ array('type' => 'int', 'length' => 11, 'not null' => TRUE, 'default' => 0));
+ db_change_field('system', 'schema_version', 'schema_version',
+ array('type' => 'int',
+ 'size' => 'small',
+ 'length' => 6,
+ 'not null' => TRUE,
+ 'default' => -1));
// Add the cache_path table.
$schema['cache_path'] = drupal_get_schema_unprocessed('system', 'cache');
$schema['cache_path']['description'] = 'Cache table used for path alias lookups.';

Patch attached based on yesterday's HEAD

AttachmentSizeStatusTest resultOperations
fixsystemweight.patch1.49 KBIdleFAILED: [[SimpleTest]]: [MySQL] Invalid patch format in fixsystemweight.patch.View details

#5

System Message - January 28, 2010 - 20:02
Status:needs review» needs work

The last submitted patch, fixsystemweight.patch, failed testing.

#6

chx - January 29, 2010 - 23:30

#7

ctmattice1 - January 30, 2010 - 20:10
Status:duplicate» needs review

I see where there is similarities with #612870: Weight fields should be int, not tinyint and it has been committed. however, there is one table that still needs correction in addition to those, the system table, without fixing it there are some upgrades from d6 to d7 that will fail immediately. I've attached a corrected patch to fix it.

AttachmentSizeStatusTest resultOperations
fixsystemweight_01.patch2.17 KBIdleFAILED: [[SimpleTest]]: [MySQL] Invalid patch format in fixsystemweight_01.patch.View details

#8

catch - January 31, 2010 - 13:41
Status:needs review» needs work

Yes system was missing from the other patch.

+++ includes/update.inc   30 Jan 2010 19:30:48 -0000
@@ -266,7 +266,33 @@ function update_fix_d7_requirements() {
+  // Change 6.x system table field values to 7.x equivelent
+  db_change_field('system', 'schema_version', 'schema_version',
...
+     'default' => -1)
+  );
+  db_drop_index('system' ,'modules'); // D6 index

Should be "equivalent", also comments should be sentence case and include a period, and above the code they describe rather than inline on the same line - see http://drupal.org/coding-standards

Additionally, where we're dropping and recreating the same index - could we put those statements next to each other?

Looks like the path index comment appears twice in the patch?

Powered by Dreditor.

#9

ctmattice1 - January 31, 2010 - 21:57
Status:needs work» needs review

Corrected patch as catch suggested. Fixed modules index where bootstrap field should not have been present.

AttachmentSizeStatusTest resultOperations
fixsystemweight_02.patch2.23 KBIdleFAILED: [[SimpleTest]]: [MySQL] Invalid patch format in fixsystemweight_02.patch.View details

#10

Magnity - February 1, 2010 - 14:28
Status:needs review» needs work

+++ includes/update.inc   31 Jan 2010 21:39:31 -0000
@@ -266,7 +266,39 @@ function update_fix_d7_requirements() {
+
+  // Add the cache_path table.
+     $schema['cache_path'] = drupal_get_schema_unprocessed('system', 'cache');
+     $schema['cache_path']['description'] = 'Cache table used for path alias lookups.';
+  // Add the cache_path table.
     $schema['cache_path'] = drupal_get_schema_unprocessed('system', 'cache');
     $schema['cache_path']['description'] = 'Cache table used for path alias lookups.';

Duplicated code?

Powered by Dreditor.

#11

ctmattice1 - February 1, 2010 - 15:22
Status:needs work» needs review

Hmmm, missed that one. Stupid copy and paste error a couple patches ago. My Bad

AttachmentSizeStatusTest resultOperations
fixsystemweight_03.patch2.03 KBIdleFAILED: [[SimpleTest]]: [MySQL] Invalid patch format in fixsystemweight_03.patch.View details

#12

catch - February 1, 2010 - 15:26
Status:needs review» reviewed & tested by the community

Looks good now.

#13

aaron - February 3, 2010 - 19:07

subscribe

#14

webchick - February 4, 2010 - 03:59
Priority:critical» normal
Status:reviewed & tested by the community» needs work

This seems to have some comment indentation issues, and also warns me about fuzz when I apply it. I can haz re-roll?

#15

catch - February 4, 2010 - 05:06
Priority:normal» critical
Status:needs work» reviewed & tested by the community

You can haz.

Also this really is critical - no Drupal 5 site can upgrade to Drupal 7 without this patch afaik.

AttachmentSizeStatusTest resultOperations
fixsystemweight.patch2.06 KBIdleFAILED: [[SimpleTest]]: [MySQL] Unable to apply patch fixsystemweight_0.patch.View details

#16

webchick - February 4, 2010 - 05:10
Status:reviewed & tested by the community» fixed

Awesome, thanks. Committed to HEAD!

#17

andypost - February 4, 2010 - 14:15
Status:fixed» needs review

What's 'lenght' parameter means for INT data-type? Is this mysql specific? Suppose no!
Here is a patch to remove length from schema definition.

AttachmentSizeStatusTest resultOperations
601642_followup.patch1.27 KBIdleFAILED: [[SimpleTest]]: [MySQL] Unable to apply patch 601642_followup.patch.View details

#18

webchick - February 4, 2010 - 17:03
Status:needs review» fixed

Oops. :P

Thanks, committed to HEAD. :)

#19

System Message - February 18, 2010 - 17:10
Status:fixed» closed

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

 
 

Drupal is a registered trademark of Dries Buytaert.