From 851bcf12f0304adf5d9a0ee988848002809e6ca3 Mon Sep 17 00:00:00 2001 From: David Rothstein Date: Sun, 10 Mar 2013 15:44:11 -0400 Subject: [PATCH] Issue #1475342 by iamEAP | Kasper Souren: Fixed D6->D7 upgrade: system_update_7007() fail. --- CHANGELOG.txt | 2 ++ ...drupal-6.duplicate-permission.database.php | 8 +++++ .../tests/upgrade/upgrade.user.test | 29 +++++++++++++++++++ modules/system/system.install | 2 +- 4 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 modules/simpletest/tests/upgrade/drupal-6.duplicate-permission.database.php diff --git a/CHANGELOG.txt b/CHANGELOG.txt index e8f99829d4f..2a703b2749a 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -1,6 +1,8 @@ Drupal 7.22, xxxx-xx-xx (development version) ----------------------- +- Fixed a bug which prevented Drupal 6 to Drupal 7 upgrades on sites which had + duplicate permission names in the User module's database tables. - Added an empty "datatype" attribute to taxonomy term and username links to make the RDFa markup upward compatible with RDFa 1.1 (minor markup addition). - Fixed a bug which caused the denial-of-service protection added in Drupal diff --git a/modules/simpletest/tests/upgrade/drupal-6.duplicate-permission.database.php b/modules/simpletest/tests/upgrade/drupal-6.duplicate-permission.database.php new file mode 100644 index 00000000000..5da5e84442b --- /dev/null +++ b/modules/simpletest/tests/upgrade/drupal-6.duplicate-permission.database.php @@ -0,0 +1,8 @@ +fields(array( + 'perm' => 'access content, access content', +)) +->condition('pid', 1) +->execute(); diff --git a/modules/simpletest/tests/upgrade/upgrade.user.test b/modules/simpletest/tests/upgrade/upgrade.user.test index c33ba117957..d33234e4312 100644 --- a/modules/simpletest/tests/upgrade/upgrade.user.test +++ b/modules/simpletest/tests/upgrade/upgrade.user.test @@ -61,3 +61,32 @@ class UserUpgradePathNoPasswordTokenTestCase extends UpgradePathTestCase { $this->assertEqual(variable_get('user_mail_register_no_approval_required_body'), '[user:name], [site:name], [site:url], [site:url-brief], [user:mail], [date:medium], [site:login-url], [user:edit-url], [user:one-time-login-url].', 'Existing email templates have been modified (password token not involved).'); } } + +/** + * Upgrade test for user.module (duplicated permission). + */ +class UserUpgradePathDuplicatedPermissionTestCase extends UpgradePathTestCase { + public static function getInfo() { + return array( + 'name' => 'User upgrade path (duplicated permission)', + 'description' => 'User upgrade path tests (duplicated permission).', + 'group' => 'Upgrade path', + ); + } + + public function setUp() { + // Path to the database dump files. + $this->databaseDumpFiles = array( + drupal_get_path('module', 'simpletest') . '/tests/upgrade/drupal-6.bare.database.php', + drupal_get_path('module', 'simpletest') . '/tests/upgrade/drupal-6.duplicate-permission.database.php', + ); + parent::setUp(); + } + + /** + * Test a successful upgrade. + */ + public function testUserUpgrade() { + $this->assertTrue($this->performUpgrade(), 'The upgrade was completed successfully.'); + } +} diff --git a/modules/system/system.install b/modules/system/system.install index 59bb2f14a6a..341a1f24afe 100644 --- a/modules/system/system.install +++ b/modules/system/system.install @@ -1890,7 +1890,7 @@ function system_update_7007() { $result = db_query("SELECT rid, perm FROM {permission} ORDER BY rid ASC"); $query = db_insert('role_permission')->fields(array('rid', 'permission')); foreach ($result as $role) { - foreach (explode(', ', $role->perm) as $perm) { + foreach (array_unique(explode(', ', $role->perm)) as $perm) { $query->values(array( 'rid' => $role->rid, 'permission' => $perm,