diff --git a/core/modules/node/node.module b/core/modules/node/node.module index d6035ac..66fbaf5 100644 --- a/core/modules/node/node.module +++ b/core/modules/node/node.module @@ -1851,7 +1851,8 @@ function node_page_title(EntityInterface $node) { */ function node_last_changed($nid, $langcode = NULL) { $language_clause = isset($langcode) ? 'langcode = :langcode' : 'default_langcode = 1'; - return db_query('SELECT changed FROM {node_field_data} WHERE nid = :nid AND ' . $language_clause, array(':nid' => $nid, ':langcode' => $langcode))->fetch()->changed; + $result = db_query('SELECT changed FROM {node_field_data} WHERE nid = :nid AND ' . $language_clause, array(':nid' => $nid, ':langcode' => $langcode))->fetch(); + return is_object($result) ? $result->changed : FALSE; } /** diff --git a/core/modules/statistics/statistics.module b/core/modules/statistics/statistics.module index 9d94e10..6a1792f 100644 --- a/core/modules/statistics/statistics.module +++ b/core/modules/statistics/statistics.module @@ -129,8 +129,10 @@ function statistics_title_list($dbfield, $dbrows) { ->fields('u', array('uid', 'name')) ->condition($dbfield, 0, '<>') ->condition('n.status', 1) + // @todo This should be actually filtering on the desired node status + // field language and just fall back to the default language. + ->condition('n.default_langcode', 1) ->orderBy($dbfield, 'DESC') - ->groupBy('n.nid') ->range(0, $dbrows) ->execute(); } diff --git a/core/modules/tracker/lib/Drupal/tracker/Tests/Views/TrackerUserUidTest.php b/core/modules/tracker/lib/Drupal/tracker/Tests/Views/TrackerUserUidTest.php index ca64eb3..804774d 100644 --- a/core/modules/tracker/lib/Drupal/tracker/Tests/Views/TrackerUserUidTest.php +++ b/core/modules/tracker/lib/Drupal/tracker/Tests/Views/TrackerUserUidTest.php @@ -33,7 +33,7 @@ public static function getInfo() { public function testUserUid() { $map = array( 'nid' => 'nid', - 'node_title' => 'title', + 'node_field_data_title' => 'title', ); $expected = array( diff --git a/core/modules/tracker/tests/modules/tracker_test_views/test_views/views.view.test_tracker_user_uid.yml b/core/modules/tracker/tests/modules/tracker_test_views/test_views/views.view.test_tracker_user_uid.yml index 9f6ee9b..a4840a4 100644 --- a/core/modules/tracker/tests/modules/tracker_test_views/test_views/views.view.test_tracker_user_uid.yml +++ b/core/modules/tracker/tests/modules/tracker_test_views/test_views/views.view.test_tracker_user_uid.yml @@ -47,7 +47,7 @@ display: fields: title: id: title - table: node + table: node_field_data field: title relationship: none group_type: group diff --git a/core/modules/tracker/tracker.module b/core/modules/tracker/tracker.module index a6ceca2..34235b9 100644 --- a/core/modules/tracker/tracker.module +++ b/core/modules/tracker/tracker.module @@ -84,7 +84,9 @@ function tracker_cron() { if ($max_nid > 0) { $batch_size = config('tracker.settings')->get('cron_index_limit'); $last_nid = FALSE; - $result = db_query_range('SELECT nid, uid, status FROM {node_field_data} WHERE nid <= :max_nid GROUP BY 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')); $count = 0; @@ -269,7 +271,9 @@ function tracker_comment_delete($comment) { * The node updated timestamp or comment timestamp. */ function _tracker_add($nid, $uid, $changed) { - $node = db_query('SELECT nid, status, uid, changed FROM {node_field_data} WHERE nid = :nid ORDER BY changed DESC, status DESC LIMIT 1', array(':nid' => $nid))->fetchObject(); + // @todo This should be actually filtering on the desired language and just + // fall back to the default language. + $node = db_query('SELECT nid, status, uid, changed FROM {node_field_data} WHERE nid = :nid AND default_langcode = 1 ORDER BY changed DESC, status DESC', array(':nid' => $nid))->fetchObject(); // Adding a comment can only increase the changed timestamp, so our // calculation here is simple. @@ -308,7 +312,9 @@ function _tracker_add($nid, $uid, $changed) { * is the greatest. */ function _tracker_calculate_changed($nid) { - $changed = db_query('SELECT changed FROM {node_field_data} WHERE nid = :nid ORDER BY changed DESC LIMIT 1', array(':nid' => $nid), array('target' => 'slave'))->fetchField(); + // @todo This should be actually filtering on the desired language and just + // fall back to the default language. + $changed = db_query('SELECT changed FROM {node_field_data} WHERE nid = :nid AND default_langcode = 1 ORDER BY changed DESC', array(':nid' => $nid), array('target' => 'slave'))->fetchField(); $latest_comment = db_query_range('SELECT cid, changed FROM {comment} WHERE nid = :nid AND status = :status ORDER BY changed DESC', 0, 1, array( ':nid' => $nid, ':status' => COMMENT_PUBLISHED, @@ -330,7 +336,9 @@ function _tracker_calculate_changed($nid) { * The last changed timestamp of the node. */ function _tracker_remove($nid, $uid = NULL, $changed = NULL) { - $node = db_query('SELECT nid, status, uid, changed FROM {node_field_data} WHERE nid = :nid ORDER BY changed DESC, status DESC LIMIT 1', array(':nid' => $nid))->fetchObject(); + // @todo This should be actually filtering on the desired language and just + // fall back to the default language. + $node = db_query('SELECT nid, status, uid, changed FROM {node_field_data} WHERE nid = :nid AND default_langcode = 1 ORDER BY changed DESC, status DESC', array(':nid' => $nid))->fetchObject(); // The user only keeps his or her subscription if both of the following are true: // (1) The node exists. diff --git a/core/modules/tracker/tracker.pages.inc b/core/modules/tracker/tracker.pages.inc index 9450605..db99e54 100644 --- a/core/modules/tracker/tracker.pages.inc +++ b/core/modules/tracker/tracker.pages.inc @@ -52,7 +52,9 @@ function tracker_page($account = NULL, $set_title = FALSE) { $nids = array_keys($tracker_data); $nodes = node_load_multiple($nids); // Now, get the data and put into the placeholder array. - $result = db_query('SELECT DISTINCT n.nid, l.comment_count FROM {node_field_data} n INNER JOIN {node_comment_statistics} l ON n.nid = l.nid WHERE n.nid IN (:nids) ORDER BY n.changed DESC', array(':nids' => $nids), array('target' => 'slave'))->fetchAllKeyed(); + // @todo This should be actually filtering on the desired language and just + // fall back to the default language. + $result = db_query('SELECT n.nid, l.comment_count FROM {node_field_data} n INNER JOIN {node_comment_statistics} l ON n.nid = l.nid WHERE n.nid IN (:nids) AND n.default_langcode = 1 ORDER BY n.changed DESC', array(':nids' => $nids), array('target' => 'slave'))->fetchAllKeyed(); foreach ($result as $nid => $comment_count) { $nodes[$nid]->last_activity = $tracker_data[$nid]->changed; $nodes[$nid]->comment_count = $comment_count;