Commit 20ab1042 authored by webchick's avatar webchick
Browse files

Issue #1927546 by alexpott, catch, Gábor Hojtsy: Fixed Langcode column added...

Issue #1927546 by alexpott, catch, Gábor Hojtsy: Fixed Langcode column added to search_index() and search_dataset() tables but there is no upgrade path.
parent 6aa308f8
......@@ -24,6 +24,7 @@ function search_schema() {
'length' => '12',
'not null' => TRUE,
'description' => 'The {languages}.langcode of the item variant.',
'default' => '',
),
'type' => array(
'type' => 'varchar',
......@@ -70,6 +71,7 @@ function search_schema() {
'length' => '12',
'not null' => TRUE,
'description' => 'The {languages}.langcode of the item variant.',
'default' => '',
),
'type' => array(
'type' => 'varchar',
......@@ -174,3 +176,41 @@ function search_update_8000() {
'search_default_module' => 'default_module',
));
}
/**
* Adds the langcode field and indexes to {search_dataset} and {search_index}.
*/
function search_update_8001() {
// In order to upgrade the existing entries to have the correct langcode we
// need to recreate search data through running cron.
db_truncate('search_dataset');
db_truncate('search_index');
db_truncate('search_node_links');
// Add the fields and indexes.
db_drop_primary_key('search_dataset');
db_add_field('search_dataset', 'langcode', array(
'type' => 'varchar',
'length' => '12',
'not null' => TRUE,
'description' => 'The {languages}.langcode of the item variant.',
'default' => '',
));
db_add_primary_key('search_dataset', array('sid', 'langcode', 'type'));
db_drop_primary_key('search_index');
db_drop_index('search_index', 'sid_type');
db_add_field('search_index', 'langcode', array(
'type' => 'varchar',
'length' => '12',
'not null' => TRUE,
'description' => 'The {languages}.langcode of the item variant.',
'default' => '',
),
array(
'indexes' => array(
'sid_type' => array('sid', 'langcode', 'type'),
),
));
db_add_primary_key('search_index', array('word', 'sid', 'langcode', 'type'));
}
......@@ -7,6 +7,8 @@
namespace Drupal\system\Tests\Upgrade;
use Drupal\Core\Database\DatabaseException;
/**
* Tests upgrading a filled database with language data.
*
......@@ -136,6 +138,17 @@ public function testLanguageUpgrade() {
$translation_string = db_query("SELECT * FROM {locales_target} WHERE lid = 22 AND language = 'ca'")->fetchObject();
$this->assertEqual($translation_string->translation, implode(LOCALE_PLURAL_DELIMITER, array('1 byte', '@count bytes')));
// Ensure that re-indexing search for a specific language does not fail. It
// does not matter if the sid exists on not. This tests whether or not
// search_update_8001() has added the langcode fields.
try {
search_reindex(1, 'node', FALSE, 'ca');
$this->pass("Calling search_reindex succeeds after upgrade.");
}
catch (DatabaseException $e) {
$this->fail("Calling search_reindex fails after upgrade.");
}
}
/**
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment