Skip to content
Snippets Groups Projects
Commit 5199f1bb authored by Dries Buytaert's avatar Dries Buytaert
Browse files

- Patch #394582 by Berdir: converted to new database abstraction layer.

parent f13d5024
Branches
Tags
2 merge requests!7452Issue #1797438. HTML5 validation is preventing form submit and not fully...,!789Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10
......@@ -14,23 +14,22 @@ function tracker_page($account = NULL, $set_title = FALSE) {
// Add CSS
drupal_add_css(drupal_get_path('module', 'tracker') . '/tracker.css', array('preprocess' => FALSE));
$header = array(
t('Type'),
t('Post'),
t('Author'),
t('Replies'),
t('Last updated')
);
$header = array(t('Type'), t('Post'), t('Author'), t('Replies'), t('Last updated'));
// TODO: These queries are very expensive, see http://drupal.org/node/105639
$query = db_select('node', 'n', array('target' => 'slave'))
->fields('n', array('nid', 'title', 'type', 'changed', 'uid'));
$query = db_select('node', 'n', array('target' => 'slave'))->extend('PagerDefault');
$query->join('users', 'u', 'n.uid = u.uid');
$query->addField('u', 'name');
$query->join('node_comment_statistics', 'l', 'n.nid = l.nid');
$query->addExpression('GREATEST(n.changed, l.last_comment_timestamp)', 'last_updated');
$query->addField('l', 'comment_count');
$query->orderBy('last_updated', 'DESC');
$query
->distinct()
->fields('n', array('nid', 'title', 'type', 'changed', 'uid'))
->fields('u', array('name'))
->fields('l', array('comment_count'))
->condition('n.status', 1)
->orderBy('last_updated', 'DESC')
->addTag('node_access')
->limit(25);
if ($account) {
if ($set_title) {
......@@ -46,12 +45,6 @@ function tracker_page($account = NULL, $set_title = FALSE) {
);
}
$query->condition('n.status', 1);
$query->distinct();
$query->extend('PagerDefault')->extend('TableSort')
->limit(25, 0)
->orderByHeader($header);
$result = $query->execute();
$rows = array();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment