Refactor query to use desired language rather than default language while providing fallback to default

Created on 26 May 2013, about 11 years ago
Updated 22 April 2024, 2 months ago

#1498674: Refactor node properties to multilingual β†’ has split various fields out from the {node} table into {node_field_data}, which has a row for each node + language.

Since there are now different rows per node, SQL queries which previously used node.status/changed/... should now use node_field_data.status/changed/..., for one of the specific language rows. Figuring out how all individual queries could now be improved to make use of language specific properties, was split into followup issues, and @todos were inserted in various parts of the code.

Three of the places where there still is a @todo, have now moved into the ForumManager class.

Remaining tasks

Figure out whether and how the query should work on different language rows in {node_field_data}, dependent on language context.

Change the code or remove the @todos, in 4 places in tracker.module.

Original issue text follows

Problem/Motivation

Simplify code

In 1498674 was the @todo

@todo This should be actually filtering on the desired language and just fall back to the default language.

On the line in the patch in comment #303:
3741, 3752, 3763, 3774 and 3792.

The line of the final patch might change but that info might help to find them.

For example,

-    $result = db_query_range('SELECT nid, uid, status FROM {node} WHERE nid <= :max_nid ORDER BY nid DESC', 0, $batch_size, array(':max_nid' => $max_nid), array('target' => 'slave'));
+    // @todo This should be actually filtering on the desired language and just
+    //   fall back to the default language.
+    $result = db_query_range('SELECT nid, uid, status FROM {node_field_data} WHERE nid <= :max_nid AND default_langcode = 1 ORDER BY nid DESC', 0, $batch_size, array(':max_nid' => $max_nid), array('target' => 'slave'));;

Proposed resolution

@todo This should be actually filtering on the desired language and just fall back to the default language.

User interface changes

No.

API changes

No.

πŸ“Œ Task
Status

Active

Version

1.0

Component
TrackerΒ  β†’

Last updated 26 days ago

No maintainer
Created by

Live updates comments and jobs are added and updated live.
  • D8MI

    (Drupal 8 Multilingual Initiative) is the tag used by the multilingual initiative to mark core issues (and some contributed module issues). For versions other than Drupal 8, use the i18n (Internationalization) tag on issues which involve or affect multilingual / multinational support. That is preferred over Translation.

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.69.0 2024