diff options
author | Dries Buytaert <dries@buytaert.net> | 2009-06-06 10:27:42 +0000 |
---|---|---|
committer | Dries Buytaert <dries@buytaert.net> | 2009-06-06 10:27:42 +0000 |
commit | c3af73ef17d0b5f6e96c7619fbd3a2f3f1115649 (patch) | |
tree | a64ec3aeca8ae3fc17cd2208d27a3b539b5fb231 | |
parent | d532753cabfe2f2cfa85279a6c4c192528bad636 (diff) | |
download | brdo-c3af73ef17d0b5f6e96c7619fbd3a2f3f1115649.tar.gz brdo-c3af73ef17d0b5f6e96c7619fbd3a2f3f1115649.tar.bz2 |
- Patch #302268 by Berdir, Dave Reid, tizzo, Ryan Palmer: TableSort and PagerQueries broken.
-rw-r--r-- | modules/comment/comment.admin.inc | 9 | ||||
-rw-r--r-- | modules/dblog/dblog.admin.inc | 29 | ||||
-rw-r--r-- | modules/poll/poll.pages.inc | 10 |
3 files changed, 18 insertions, 30 deletions
diff --git a/modules/comment/comment.admin.inc b/modules/comment/comment.admin.inc index 5d29c9b0f..e41a0d63c 100644 --- a/modules/comment/comment.admin.inc +++ b/modules/comment/comment.admin.inc @@ -66,19 +66,18 @@ function comment_admin_overview($type = 'new', $arg) { 'operations' => array('data' => t('Operations')), ); - $query = db_select('comment', 'c'); + $query = db_select('comment', 'c')->extend('PagerDefault')->extend('TableSort'); $query->join('users', 'u', 'u.uid = c.uid'); $query->join('node', 'n', 'n.nid = c.nid'); $query->addField('u', 'name', 'registered_name'); $query->addField('n', 'title', 'node_title'); - $query + $result = $query ->fields('c', array('subject', 'nid', 'cid', 'comment', 'timestamp', 'status', 'name', 'homepage')) ->fields('u', array('uid')) ->condition('c.status', $status) - ->extend('PagerDefault')->extend('TableSort') ->limit(50) - ->orderByHeader($header); - $result = $query->execute(); + ->orderByHeader($header) + ->execute(); // Build a table listing the appropriate comments. diff --git a/modules/dblog/dblog.admin.inc b/modules/dblog/dblog.admin.inc index 53389586d..9e045acbb 100644 --- a/modules/dblog/dblog.admin.inc +++ b/modules/dblog/dblog.admin.inc @@ -51,7 +51,7 @@ function dblog_overview() { $build['dblog_clear_log_form'] = drupal_get_form('dblog_clear_log_form'); $header = array( - ' ', + '', // Icon column. array('data' => t('Type'), 'field' => 'w.type'), array('data' => t('Date'), 'field' => 'w.wid', 'sort' => 'desc'), t('Message'), @@ -59,26 +59,18 @@ function dblog_overview() { array('data' => t('Operations')), ); - $query = db_select('watchdog', 'w'); + $query = db_select('watchdog', 'w')->extend('PagerDefault')->extend('TableSort'); $query->join('users', 'u', 'w.uid = u.uid'); $query ->fields('w', array('wid', 'uid', 'severity', 'type', 'timestamp', 'message', 'variables', 'link')) ->addField('u', 'name'); if (!empty($filter['where'])) { - $query - ->where($filter['where'], $filter['args']) - ->extend('PagerDefault')->extend('TableSort') - ->limit(50, 0) - ->orderByHeader($header); - $result = $query->execute(); - } - else { - $query - ->extend('PagerDefault')->extend('TableSort') - ->limit(50) - ->orderByHeader($header); - $result = $query->execute(); + $query->where($filter['where'], $filter['args']); } + $result = $query + ->limit(50) + ->orderByHeader($header) + ->execute(); foreach ($result as $dblog) { $rows[] = array('data' => @@ -120,16 +112,15 @@ function dblog_top($type) { $count_query->addExpression('COUNT(DISTINCT(message))'); $count_query->condition('type', $type); - $query = db_select('watchdog', 'w'); + $query = db_select('watchdog', 'w')->extend('PagerDefault')->extend('TableSort'); $query->addExpression('COUNT(wid)', 'count'); $query = $query ->fields('w', array('message', 'variables')) ->condition('w.type', $type) ->groupBy('message') ->groupBy('variables') - ->extend('PagerDefault')->extend('TableSort') - ->limit(30); - $query = $query->orderByHeader($header); + ->limit(30) + ->orderByHeader($header); $query->setCountQuery($count_query); $result = $query->execute(); diff --git a/modules/poll/poll.pages.inc b/modules/poll/poll.pages.inc index ebd12cbe9..7a23597b6 100644 --- a/modules/poll/poll.pages.inc +++ b/modules/poll/poll.pages.inc @@ -58,19 +58,17 @@ function poll_votes($node) { $header[] = array('data' => t('Vote'), 'field' => 'pc.chtext'); $header[] = array('data' => t('Timestamp'), 'field' => 'pv.timestamp', 'sort' => 'desc'); - $select = db_select('poll_vote', 'pv'); + $select = db_select('poll_vote', 'pv')->extend('PagerDefault')->extend('TableSort'); $select->join('poll_choice', 'pc', 'pv.chid = pc.chid'); $select->join('users', 'u', 'pv.uid = u.uid'); - $queried_votes = $select->fields('pv', array('chid', 'uid', 'hostname', 'timestamp', 'nid')) + $queried_votes = $select + ->fields('pv', array('chid', 'uid', 'hostname', 'timestamp', 'nid')) ->fields('pc', array('chtext')) ->fields('u', array('name')) ->condition('pv.nid', $node->nid) - ->extend('PagerDefault') ->limit($votes_per_page) - ->extend('TableSort') ->orderByHeader($header) - ->execute() - ->fetchAllAssoc('hostname'); + ->execute(); $rows = array(); foreach ($queried_votes as $vote) { |