diff -u b/core/modules/node/node.module b/core/modules/node/node.module --- b/core/modules/node/node.module +++ b/core/modules/node/node.module @@ -1620,8 +1620,8 @@ // Load results. $find = $query - // Add the language code of the indexed item to the result of the query, since the node - // will be rendered using the respective language. + // Add the language code of the indexed item to the result of the query, + // since the node will be rendered using the respective language. ->fields('i', array('langcode')) ->limit(10) ->execute(); @@ -2658,7 +2658,8 @@ return; } - // The indexing throttle should be aware of the number of language variants of a node. + // The indexing throttle should be aware of the number of language variants + // of a node. $counter = 0; foreach (node_load_multiple($nids) as $node) { // Determine when the maximum number of indexable items is reached. diff -u b/core/modules/search/lib/Drupal/search/Tests/SearchMultilingualEntityTest.php b/core/modules/search/lib/Drupal/search/Tests/SearchMultilingualEntityTest.php --- b/core/modules/search/lib/Drupal/search/Tests/SearchMultilingualEntityTest.php +++ b/core/modules/search/lib/Drupal/search/Tests/SearchMultilingualEntityTest.php @@ -12,8 +12,15 @@ */ class SearchMultilingualEntityTest extends SearchTestBase { + /** + * List of searchable nodes. + * + * @var array + */ protected $searchable_nodes = array(); + protected static $modules = array('language', 'locale', 'comment'); + public static function getInfo() { return array( 'name' => 'Multilingual entities', @@ -23,7 +30,7 @@ } function setUp() { - parent::setUp('language', 'locale', 'comment'); + parent::setUp(); // Add two new languages. $language = (object) array( @@ -38,7 +45,7 @@ language_save($language); // Make the body field translatable. - // (The parent class has already created the article and page content types.) + // The parent class has already created the article and page content types. $field = field_info_field('body'); $field['translatable'] = TRUE; field_update_field($field); @@ -77,6 +84,9 @@ } } + /** + * Tests for indexing throttle with nodes in multiple languages. + */ function testIndexingThrottle() { // Index only 4 items per cron run. config('search.settings')->set('index.cron_limit', 4)->save(); @@ -91,23 +101,25 @@ - // variants. Indexing the third would exceed the throttle limit, so we expect - // that only the first two will be indexed. + // variants. Indexing the third would exceed the throttle limit, so we + // expect that only the first two will be indexed. $status = module_invoke('node', 'search_status'); - $this->assertEqual($status['remaining'], 1, t('Remaining items after updating the search index is 1.')); + $this->assertEqual($status['remaining'], 1, 'Remaining items after updating the search index is 1.'); } + /** + * Tests searching nodes with multiple languages. + */ function testSearchingMultilingualFieldValues() { // Update the index and then run the shutdown method. // See testIndexingThrottle() for further explanation. node_update_index(); search_update_totals(); foreach ($this->searchable_nodes as $node) { - // Each searchable node that we created contains values in the body field in one or more - // languages. Let's pick the last language variant from the body array and execute a search - // using that as a search keyword. + // Each searchable node that we created contains values in the body field + // in one or more languages. Let's pick the last language variant from the + // body array and execute a search using that as a search keyword. $body_language_variant = end($node->body); $search_result = node_search_execute($body_language_variant[0]['value']); // See whether we get the same node as a result. - $this->assertEqual($search_result[0]['node']->nid, $node->nid, t('The search has resulted the correct node.')); + $this->assertEqual($search_result[0]['node']->nid, $node->nid, 'The search has resulted the correct node.'); } } } -