diff -u b/core/modules/search/search.install b/core/modules/search/search.install --- b/core/modules/search/search.install +++ b/core/modules/search/search.install @@ -181,6 +181,12 @@ * 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( @@ -209,4 +215,2 @@ db_add_primary_key('search_index', array('word', 'sid', 'langcode', 'type')); - - // How do we upgrade the existing entries to have the correct langcode? } diff -u b/core/modules/system/lib/Drupal/system/Tests/Upgrade/LanguageUpgradePathTest.php b/core/modules/system/lib/Drupal/system/Tests/Upgrade/LanguageUpgradePathTest.php --- b/core/modules/system/lib/Drupal/system/Tests/Upgrade/LanguageUpgradePathTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Upgrade/LanguageUpgradePathTest.php @@ -7,6 +7,8 @@ namespace Drupal\system\Tests\Upgrade; +use Drupal\Core\Database\DatabaseException; + /** * Tests upgrading a filled database with language data. * @@ -137,8 +139,16 @@ $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 the search does not fail. - search_reindex(); + // 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."); + } } /**