diff options
author | Angie Byron <webchick@24967.no-reply.drupal.org> | 2010-10-05 20:04:19 +0000 |
---|---|---|
committer | Angie Byron <webchick@24967.no-reply.drupal.org> | 2010-10-05 20:04:19 +0000 |
commit | 02cc38e0c2c26b9301f2cf53c271129c12468d55 (patch) | |
tree | 092b0276b60b52fbdd73d50ce17e0e0298ad5615 | |
parent | facc581013f781bd7737d02700a5ffe2a253e5f3 (diff) | |
download | brdo-02cc38e0c2c26b9301f2cf53c271129c12468d55.tar.gz brdo-02cc38e0c2c26b9301f2cf53c271129c12468d55.tar.bz2 |
#812416 by plach, Damien Tournoud: Fix Locale upgrade path.
-rw-r--r-- | modules/locale/locale.install | 15 | ||||
-rw-r--r-- | modules/simpletest/simpletest.info | 1 | ||||
-rw-r--r-- | modules/simpletest/tests/upgrade/drupal-6.locale.database.php | 277 | ||||
-rw-r--r-- | modules/system/system.install | 2 |
4 files changed, 285 insertions, 10 deletions
diff --git a/modules/locale/locale.install b/modules/locale/locale.install index 6b38238e1..5398c9495 100644 --- a/modules/locale/locale.install +++ b/modules/locale/locale.install @@ -46,6 +46,7 @@ function locale_update_7000() { */ function locale_update_7001() { require_once DRUPAL_ROOT . '/includes/language.inc'; + require_once DRUPAL_ROOT . '/includes/locale.inc'; require_once DRUPAL_ROOT . '/modules/locale/locale.module'; switch (variable_get('language_negotiation', 0)) { @@ -62,9 +63,12 @@ function locale_update_7001() { // Drupal 7 path prefixes are always shown if not empty. Hence we need to // ensure that the default language has an empty prefix to avoid breaking // the site URLs with a prefix that previously was missing. + $default = language_default(); + $default->prefix = ''; + variable_set('language_default', $default); db_update('languages') - ->fields(array('prefix' => '')) - ->condition('language', language_default()->language) + ->fields(array('prefix' => $default->prefix)) + ->condition('language', $default->language) ->execute(); break; @@ -90,13 +94,6 @@ function locale_update_7001() { $provider_weights = array_flip(array_keys(locale_language_negotiation_info())); variable_set("locale_language_providers_weight_$type", $provider_weights); - // Update language switcher block delta. - db_update('block') - ->fields(array('delta' => $type)) - ->condition('module', 'locale') - ->condition('delta', 0) - ->execute(); - // Unset the old language negotiation system variable. variable_del('language_negotiation'); diff --git a/modules/simpletest/simpletest.info b/modules/simpletest/simpletest.info index c7e113ac9..c92007b04 100644 --- a/modules/simpletest/simpletest.info +++ b/modules/simpletest/simpletest.info @@ -43,3 +43,4 @@ files[] = tests/upgrade/upgrade.comment.test files[] = tests/upgrade/upgrade.node.test files[] = tests/upgrade/upgrade.taxonomy.test files[] = tests/upgrade/upgrade.upload.test +files[] = tests/upgrade/upgrade.locale.test diff --git a/modules/simpletest/tests/upgrade/drupal-6.locale.database.php b/modules/simpletest/tests/upgrade/drupal-6.locale.database.php new file mode 100644 index 000000000..d4ea09f73 --- /dev/null +++ b/modules/simpletest/tests/upgrade/drupal-6.locale.database.php @@ -0,0 +1,277 @@ +<?php +// $Id$ + +/** + * Database additions for locale tests. + */ + +db_create_table('languages', array( + 'fields' => array( + 'language' => array( + 'type' => 'varchar', + 'length' => 12, + 'not null' => TRUE, + 'default' => '', + ), + 'name' => array( + 'type' => 'varchar', + 'length' => 64, + 'not null' => TRUE, + 'default' => '', + ), + 'native' => array( + 'type' => 'varchar', + 'length' => 64, + 'not null' => TRUE, + 'default' => '', + ), + 'direction' => array( + 'type' => 'int', + 'not null' => TRUE, + 'default' => 0, + ), + 'enabled' => array( + 'type' => 'int', + 'not null' => TRUE, + 'default' => 0, + ), + 'plurals' => array( + 'type' => 'int', + 'not null' => TRUE, + 'default' => 0, + ), + 'formula' => array( + 'type' => 'varchar', + 'length' => 128, + 'not null' => TRUE, + 'default' => '', + ), + 'domain' => array( + 'type' => 'varchar', + 'length' => 128, + 'not null' => TRUE, + 'default' => '', + ), + 'prefix' => array( + 'type' => 'varchar', + 'length' => 128, + 'not null' => TRUE, + 'default' => '', + ), + 'weight' => array( + 'type' => 'int', + 'not null' => TRUE, + 'default' => 0, + ), + 'javascript' => array( + 'type' => 'varchar', + 'length' => 32, + 'not null' => TRUE, + 'default' => '', + ), + ), + 'primary key' => array( + 'language', + ), + 'indexes' => array( + 'list' => array( + 'weight', + 'name', + ), + ), + 'module' => 'locale', + 'name' => 'languages', +)); +db_insert('languages')->fields(array( + 'language', + 'name', + 'native', + 'direction', + 'enabled', + 'plurals', + 'formula', + 'domain', + 'prefix', + 'weight', + 'javascript', +)) +->values(array( + 'language' => 'en', + 'name' => 'English', + 'native' => 'English', + 'direction' => '0', + 'enabled' => '1', + 'plurals' => '0', + 'formula' => '', + 'domain' => 'http://en.example.com', + 'prefix' => 'en', + 'weight' => '0', + 'javascript' => '', +)) +->values(array( + 'language' => 'fr', + 'name' => 'French', + 'native' => 'Français', + 'direction' => '0', + 'enabled' => '1', + 'plurals' => '2', + 'formula' => '($n>1)', + 'domain' => '', + 'prefix' => 'fr', + 'weight' => '-3', + 'javascript' => '51e92dcfe1491f4595b9df7f3b287753', +)) +->execute(); + +db_create_table('locales_source', array( + 'fields' => array( + 'lid' => array( + 'type' => 'serial', + 'not null' => TRUE, + ), + 'location' => array( + 'type' => 'varchar', + 'length' => 255, + 'not null' => TRUE, + 'default' => '', + ), + 'textgroup' => array( + 'type' => 'varchar', + 'length' => 255, + 'not null' => TRUE, + 'default' => 'default', + ), + 'source' => array( + 'type' => 'text', + 'mysql_type' => 'blob', + 'not null' => TRUE, + ), + 'version' => array( + 'type' => 'varchar', + 'length' => 20, + 'not null' => TRUE, + 'default' => 'none', + ), + ), + 'primary key' => array( + 'lid', + ), + 'indexes' => array( + 'source' => array( + array( + 'source', + 30, + ), + ), + ), + 'module' => 'locale', + 'name' => 'locales_source', +)); + +db_create_table('locales_target', array( + 'fields' => array( + 'lid' => array( + 'type' => 'int', + 'not null' => TRUE, + 'default' => 0, + ), + 'translation' => array( + 'type' => 'text', + 'mysql_type' => 'blob', + 'not null' => TRUE, + ), + 'language' => array( + 'type' => 'varchar', + 'length' => 12, + 'not null' => TRUE, + 'default' => '', + ), + 'plid' => array( + 'type' => 'int', + 'not null' => TRUE, + 'default' => 0, + ), + 'plural' => array( + 'type' => 'int', + 'not null' => TRUE, + 'default' => 0, + ), + ), + 'primary key' => array( + 'language', + 'lid', + 'plural', + ), + 'indexes' => array( + 'lid' => array( + 'lid', + ), + 'plid' => array( + 'plid', + ), + 'plural' => array( + 'plural', + ), + ), + 'module' => 'locale', + 'name' => 'locales_target', +)); + +// Enable the locale module. +db_update('system')->fields(array( + 'status' => 1, + 'schema_version' => '6006', +)) +->condition('type', 'module') +->condition('name', 'locale') +->execute(); + +// Set the default language. +db_insert('variable')->fields(array( + 'name', + 'value', +)) +->values(array( + 'name' => 'language_default', + 'value' => 'O:8:"stdClass":11:{s:8:"language";s:2:"fr";s:4:"name";s:6:"French";s:6:"native";s:9:"Français";s:9:"direction";s:1:"0";s:7:"enabled";i:1;s:7:"plurals";s:1:"2";s:7:"formula";s:6:"($n>1)";s:6:"domain";s:0:"";s:6:"prefix";s:0:"";s:6:"weight";s:2:"-3";s:10:"javascript";s:32:"51e92dcfe1491f4595b9df7f3b287753";}', +)) +->values(array( + 'name' => 'language_count', + 'value' => 'i:2;', +)) +->values(array( + 'name' => 'language_negotiation', + 'value' => 'i:0;', +)) +->execute(); + +// Add the language switcher block in the left region. +db_insert('blocks')->fields(array( + 'module', + 'delta', + 'theme', + 'status', + 'weight', + 'region', + 'custom', + 'throttle', + 'visibility', + 'pages', + 'title', + 'cache', +)) +->values(array( + 'module' => 'locale', + 'delta' => '0', + 'theme' => 'garland', + 'status' => '1', + 'weight' => '0', + 'region' => 'left', + 'custom' => '0', + 'throttle' => '0', + 'visibility' => '0', + 'pages' => '', + 'title' => '', + 'cache' => '-1', +)) +->execute(); diff --git a/modules/system/system.install b/modules/system/system.install index f3d97c567..087b130b0 100644 --- a/modules/system/system.install +++ b/modules/system/system.install @@ -1813,7 +1813,7 @@ function system_update_7004(&$sandbox) { '0' => 'active', '1' => 'new', ), - 'locale' => array('0' => 'language-switcher'), + 'locale' => array('0' => LANGUAGE_TYPE_INTERFACE), 'node' => array('0' => 'syndicate'), 'poll' => array('0' => 'recent'), 'profile' => array('0' => 'author-information'), |