role_permission required to upgrade from D6 to D7

gordon - July 20, 2009 - 02:43
Project:Drupal
Version:7.x-dev
Component:update system
Category:bug report
Priority:normal
Assigned:gordon
Status:closed
Description

To run an upgrade the role_permission table needs to exist or an error is caused which stops the upgrade pages from getting to the next selection page.

I have added to the update_fix_d7_requirements() to create the role_permission table so that it can get past the check.

This still gets updated during the upgrade, but the table exists.

AttachmentSizeStatusTest resultOperations
0002-role_permission-required-to-upgrade.patch2.75 KBIdleFailed: Failed to apply patch.View details

#1

David_Rothstein - July 22, 2009 - 21:09

Strangely, I am able to reproduce this issue, but only occasionally. Most of the time I've tried upgrading, it works fine. But on a few occasions (with no discernible pattern whatsoever), I have seen this error.

In particular, the error message occurs during system_update_7007() and consists of:

An error occurred.
Path: http://localhost/drupal/update.php?id=2&op=do
Message:
PDOException: SQLSTATE[42S01]: Base table or view already exists: 1050 Table 'role_permission' already exists: CREATE TABLE {role_permission} (
`rid` INT unsigned NOT NULL,
`permission` VARCHAR(64) NOT NULL DEFAULT '',
PRIMARY KEY (rid, permission),
INDEX permission (permission)
) ENGINE = InnoDB DEFAULT CHARACTER SET UTF8; Array
(
)
in db_create_table() (line 2096 of /home/droth/web/drupal/includes/database/database.inc).

It would be ideal if we could figure out what's causing this issue, before trying to work around it - but I have no ideas at the moment, and the fact that it's only an intermittent problem is troubling :)

#2

System Message - July 29, 2009 - 08:10
Status:needs review» needs work

The last submitted patch failed testing.

#3

gordon - August 5, 2009 - 12:13

Updated version of the patch

AttachmentSizeStatusTest resultOperations
0001-role_permission-required-to-upgrade.patch2.78 KBIdleFailed: Failed to apply patch.View details

#4

catch - August 5, 2009 - 23:48

I've had this when a contrib (7) module has been installed, which calls user_access(), such as devel does in hook_boot().

#5

gordon - August 5, 2009 - 23:51
Status:needs work» needs review

Opps forgot to change the status

#6

gordon - August 5, 2009 - 23:54
Priority:critical» normal

Yes this explains it, and why it is going to be a problem in a future.

#7

System Message - August 22, 2009 - 18:40
Status:needs review» needs work

The last submitted patch failed testing.

#8

gordon - August 23, 2009 - 02:02
Status:needs work» needs review

Fix up the conflicts in the patch

AttachmentSizeStatusTest resultOperations
0001-role_permission-required-to-upgrade.patch2.73 KBIdleFailed: Failed to apply patch.View details

#9

System Message - August 31, 2009 - 09:18
Status:needs review» needs work

The last submitted patch failed testing.

#10

lilou - August 31, 2009 - 12:38
Status:needs work» needs review

HEAD is broken.

#11

System Message - September 30, 2009 - 07:40
Status:needs review» needs work

The last submitted patch failed testing.

#12

catch - October 24, 2009 - 01:32
Status:needs work» needs review

Re-rolled.

AttachmentSizeStatusTest resultOperations
role_permission.patch2.07 KBIdleUnable to apply patch role_permission.patchView details

#13

webchick - October 24, 2009 - 01:35
Status:needs review» needs work

+++ includes/update.inc 24 Oct 2009 01:31:35 -0000
@@ -128,10 +128,15 @@ function update_fix_d7_requirements() {
-    // add empty columns for now.
+    // Add empty columns for now.

Ahaha. I am a slacker for not catching that in the last patch. :)

+++ includes/update.inc 24 Oct 2009 01:31:35 -0000
@@ -128,10 +128,15 @@ function update_fix_d7_requirements() {
+    variable_set('update_d7_requirements', TRUE);

Why are you setting this here when it's already being set further down?

+++ modules/system/system.install 24 Oct 2009 01:31:37 -0000
@@ -2012,7 +2012,9 @@ function system_update_7007() {
+  if (!db_table_exists('role_permission')) {
+    db_create_table('role_permission', $schema['role_permission']);
+  }

Why do we need this hunk anymore if we're taking care of this in update_fix_d7_requirements() now?

This review is powered by Dreditor.

#14

catch - October 24, 2009 - 01:36
Status:needs work» needs review

Removed bogus variable_set(), removed table creation from 7007()

AttachmentSizeStatusTest resultOperations
role_permission.patch2.53 KBIdleUnable to apply patch role_permission_0.patchView details

#15

webchick - October 24, 2009 - 01:43
Status:needs review» needs work

+++ includes/update.inc 24 Oct 2009 01:35:47 -0000
@@ -128,10 +128,14 @@ function update_fix_d7_requirements() {
+    $schema['role_permission'] = drupal_get_schema_unprocessed('user', 'role_permission');
+++ modules/system/system.install 24 Oct 2009 01:35:48 -0000
@@ -1992,28 +1992,6 @@ function system_update_7006() {
-  $schema['role_permission'] = array(
-    'fields' => array(
-      'rid' => array(
-        'type' => 'int',
-        'unsigned' => TRUE,
-        'not null' => TRUE,
-      ),
-      'permission' => array(
-        'type' => 'varchar',
-        'length' => 64,
-        'not null' => TRUE,
-        'default' => '',
-      ),
-    ),
-    'primary key' => array('rid', 'permission'),
-    'indexes' => array(
-      'permission' => array('permission'),
-    ),
-  );
-
-  db_create_table('role_permission', $schema['role_permission']);
-

Oops. It just occurred to me from reading this hunk that we need to add that table definition to update_fix_d7_requirements(). drupal_get_schema_unprocessed() is going to get the /current/ schema of the table, which may or may not be the same in 7.0 as it is in 7.24.

See also http://drupal.org/node/150220

I'm on crack. Are you, too?

#16

catch - October 24, 2009 - 01:44
Status:needs work» needs review

Include full schema definition in update_fix_d7_requirements().

AttachmentSizeStatusTest resultOperations
role_permission.patch2.91 KBIgnoredNoneNone

#17

webchick - October 24, 2009 - 01:47
Status:needs review» fixed

Awesome, think we got it now. :)

Committed to HEAD!

#18

System Message - November 7, 2009 - 01:50
Status:fixed» closed

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

 
 

Drupal is a registered trademark of Dries Buytaert.