diff --git a/core/includes/database.inc b/core/includes/database.inc index 92d4119f70d..216c88e51d8 100644 --- a/core/includes/database.inc +++ b/core/includes/database.inc @@ -29,10 +29,10 @@ use Drupal\Core\Database\Query\Condition; * inherits much of its syntax and semantics. * * Most Drupal database SELECT queries are performed by a call to db_query() or - * db_query_range(). Module authors should also consider using the PagerDefault - * Extender for queries that return results that need to be presented on - * multiple pages, and the Tablesort Extender for generating appropriate queries - * for sortable tables. + * db_query_range(). Module authors should also consider using the + * Drupal\Core\Database\Query\PagerSelectExtender for queries that return + * results that need to be presented on multiple pages, and the Tablesort + * Extender for generating appropriate queries for sortable tables. * * For example, one might wish to return a list of the most recent 10 nodes * authored by a given user. Instead of directly issuing the SQL query diff --git a/core/includes/pager.inc b/core/includes/pager.inc index 9419cededb2..40d9c01078f 100644 --- a/core/includes/pager.inc +++ b/core/includes/pager.inc @@ -1,174 +1,10 @@ addTag('pager'); - } - - /** - * Override the execute method. - * - * Before we run the query, we need to add pager-based range() instructions - * to it. - */ - public function execute() { - - // Add convenience tag to mark that this is an extended query. We have to - // do this in the constructor to ensure that it is set before preExecute() - // gets called. - if (!$this->preExecute($this)) { - return NULL; - } - - // A NULL limit is the "kill switch" for pager queries. - if (empty($this->limit)) { - return; - } - $this->ensureElement(); - - $total_items = $this->getCountQuery()->execute()->fetchField(); - $current_page = pager_default_initialize($total_items, $this->limit, $this->element); - $this->range($current_page * $this->limit, $this->limit); - - // Now that we've added our pager-based range instructions, run the query normally. - return $this->query->execute(); - } - - /** - * Ensure that there is an element associated with this query. - * If an element was not specified previously, then the value of the - * $maxElement counter is taken, after which the counter is incremented. - * - * After running this method, access $this->element to get the element for this - * query. - */ - protected function ensureElement() { - if (!isset($this->element)) { - $this->element = self::$maxElement++; - } - } - - /** - * Specify the count query object to use for this pager. - * - * You will rarely need to specify a count query directly. If not specified, - * one is generated off of the pager query itself. - * - * @param SelectQueryInterface $query - * The count query object. It must return a single row with a single column, - * which is the total number of records. - */ - public function setCountQuery(SelectInterface $query) { - $this->customCountQuery = $query; - } - - /** - * Retrieve the count query for this pager. - * - * The count query may be specified manually or, by default, taken from the - * query we are extending. - * - * @return SelectQueryInterface - * A count query object. - */ - public function getCountQuery() { - if ($this->customCountQuery) { - return $this->customCountQuery; - } - else { - return $this->query->countQuery(); - } - } - - /** - * Specify the maximum number of elements per page for this query. - * - * The default if not specified is 10 items per page. - * - * @param $limit - * An integer specifying the number of elements per page. If passed a false - * value (FALSE, 0, NULL), the pager is disabled. - */ - public function limit($limit = 10) { - $this->limit = $limit; - return $this; - } - - /** - * Specify the element ID for this pager query. - * - * The element is used to differentiate different pager queries on the same - * page so that they may be operated independently. If you do not specify an - * element, every pager query on the page will get a unique element. If for - * whatever reason you want to explicitly define an element for a given query, - * you may do so here. - * - * Setting the element here also increments the static $maxElement counter, - * which is used for determining the $element when there's none specified. - * - * Note that no collision detection is done when setting an element ID - * explicitly, so it is possible for two pagers to end up using the same ID - * if both are set explicitly. - * - * @param $element - */ - public function element($element) { - $this->element = $element; - if ($element >= self::$maxElement) { - self::$maxElement = $element + 1; - } - return $this; - } -} - /** * Returns the current page being requested for display within a pager. * @@ -206,10 +42,11 @@ function pager_find_page($element = 0) { * If the items being displayed result from a database query performed using * Drupal's database API, and if you have control over the construction of the * database query, you do not need to call this function directly; instead, you - * can simply extend the query object with the 'PagerDefault' extender before - * executing it. For example: + * can simply extend the query object with the 'PagerSelectExtender' extender + * before executing it. For example: * @code - * $query = db_select('some_table')->extend('PagerDefault'); + * $query = db_select('some_table') + * ->extend('Drupal\Core\Database\Query\PagerSelectExtender'); * @endcode * * However, if you are using a different method for generating the items to be diff --git a/core/lib/Drupal/Core/Database/Query/ExtendableInterface.php b/core/lib/Drupal/Core/Database/Query/ExtendableInterface.php index 1ebac45ac19..01dcc90f867 100644 --- a/core/lib/Drupal/Core/Database/Query/ExtendableInterface.php +++ b/core/lib/Drupal/Core/Database/Query/ExtendableInterface.php @@ -25,8 +25,7 @@ interface ExtendableInterface { * @param $extender_name * The base name of the extending class. The base name will be checked * against the current database connection to allow driver-specific subclasses - * as well, using the same logic as the query objects themselves. For example, - * PagerDefault_mysql is the MySQL-specific override for PagerDefault. + * as well, using the same logic as the query objects themselves. * @return Drupal\Core\Database\Query\ExtendableInterface * The extender object, which now contains a reference to this object. */ diff --git a/core/lib/Drupal/Core/Database/Query/PagerSelectExtender.php b/core/lib/Drupal/Core/Database/Query/PagerSelectExtender.php new file mode 100644 index 00000000000..0668fa5cf91 --- /dev/null +++ b/core/lib/Drupal/Core/Database/Query/PagerSelectExtender.php @@ -0,0 +1,172 @@ +addTag('pager'); + } + + /** + * Override the execute method. + * + * Before we run the query, we need to add pager-based range() instructions + * to it. + */ + public function execute() { + + // Add convenience tag to mark that this is an extended query. We have to + // do this in the constructor to ensure that it is set before preExecute() + // gets called. + if (!$this->preExecute($this)) { + return NULL; + } + + // A NULL limit is the "kill switch" for pager queries. + if (empty($this->limit)) { + return; + } + $this->ensureElement(); + + $total_items = $this->getCountQuery()->execute()->fetchField(); + $current_page = pager_default_initialize($total_items, $this->limit, $this->element); + $this->range($current_page * $this->limit, $this->limit); + + // Now that we've added our pager-based range instructions, run the query normally. + return $this->query->execute(); + } + + /** + * Ensure that there is an element associated with this query. + * If an element was not specified previously, then the value of the + * $maxElement counter is taken, after which the counter is incremented. + * + * After running this method, access $this->element to get the element for this + * query. + */ + protected function ensureElement() { + if (!isset($this->element)) { + $this->element = self::$maxElement++; + } + } + + /** + * Specify the count query object to use for this pager. + * + * You will rarely need to specify a count query directly. If not specified, + * one is generated off of the pager query itself. + * + * @param SelectQueryInterface $query + * The count query object. It must return a single row with a single column, + * which is the total number of records. + */ + public function setCountQuery(SelectInterface $query) { + $this->customCountQuery = $query; + } + + /** + * Retrieve the count query for this pager. + * + * The count query may be specified manually or, by default, taken from the + * query we are extending. + * + * @return SelectQueryInterface + * A count query object. + */ + public function getCountQuery() { + if ($this->customCountQuery) { + return $this->customCountQuery; + } + else { + return $this->query->countQuery(); + } + } + + /** + * Specify the maximum number of elements per page for this query. + * + * The default if not specified is 10 items per page. + * + * @param $limit + * An integer specifying the number of elements per page. If passed a false + * value (FALSE, 0, NULL), the pager is disabled. + */ + public function limit($limit = 10) { + $this->limit = $limit; + return $this; + } + + /** + * Specify the element ID for this pager query. + * + * The element is used to differentiate different pager queries on the same + * page so that they may be operated independently. If you do not specify an + * element, every pager query on the page will get a unique element. If for + * whatever reason you want to explicitly define an element for a given query, + * you may do so here. + * + * Setting the element here also increments the static $maxElement counter, + * which is used for determining the $element when there's none specified. + * + * Note that no collision detection is done when setting an element ID + * explicitly, so it is possible for two pagers to end up using the same ID + * if both are set explicitly. + * + * @param $element + */ + public function element($element) { + $this->element = $element; + if ($element >= self::$maxElement) { + self::$maxElement = $element + 1; + } + return $this; + } +} diff --git a/core/modules/aggregator/aggregator.pages.inc b/core/modules/aggregator/aggregator.pages.inc index 7f820770fed..fcc61b00236 100644 --- a/core/modules/aggregator/aggregator.pages.inc +++ b/core/modules/aggregator/aggregator.pages.inc @@ -134,7 +134,7 @@ function aggregator_load_feed_items($type, $data = NULL) { } $result = $query - ->extend('PagerDefault') + ->extend('Drupal\Core\Database\Query\PagerSelectExtender') ->limit(20) ->orderBy('i.timestamp', 'DESC') ->orderBy('i.iid', 'DESC') diff --git a/core/modules/comment/comment.admin.inc b/core/modules/comment/comment.admin.inc index 4329492a565..3a853df6a81 100644 --- a/core/modules/comment/comment.admin.inc +++ b/core/modules/comment/comment.admin.inc @@ -79,7 +79,9 @@ function comment_admin_overview($form, &$form_state, $arg) { 'operations' => array('data' => t('Operations')), ); - $query = db_select('comment', 'c')->extend('PagerDefault')->extend('TableSort'); + $query = db_select('comment', 'c') + ->extend('Drupal\Core\Database\Query\PagerSelectExtender') + ->extend('TableSort'); $query->join('node', 'n', 'n.nid = c.nid'); $query->addField('n', 'title', 'node_title'); $query->addTag('node_access'); diff --git a/core/modules/comment/comment.module b/core/modules/comment/comment.module index 4fa8fee71d6..5684731cb19 100644 --- a/core/modules/comment/comment.module +++ b/core/modules/comment/comment.module @@ -849,7 +849,8 @@ function comment_node_page_additions(Node $node) { * to consider the trailing "/" so we use a substring only. */ function comment_get_thread(Node $node, $mode, $comments_per_page) { - $query = db_select('comment', 'c')->extend('PagerDefault'); + $query = db_select('comment', 'c') + ->extend('Drupal\Core\Database\Query\PagerSelectExtender'); $query->addField('c', 'cid'); $query ->condition('c.nid', $node->nid) diff --git a/core/modules/dblog/dblog.admin.inc b/core/modules/dblog/dblog.admin.inc index b2da7eddf2d..dafc91b021c 100644 --- a/core/modules/dblog/dblog.admin.inc +++ b/core/modules/dblog/dblog.admin.inc @@ -37,7 +37,9 @@ function dblog_overview() { array('data' => t('Operations')), ); - $query = db_select('watchdog', 'w')->extend('PagerDefault')->extend('TableSort'); + $query = db_select('watchdog', 'w') + ->extend('Drupal\Core\Database\Query\PagerSelectExtender') + ->extend('TableSort'); $query->leftJoin('users', 'u', 'w.uid = u.uid'); $query ->fields('w', array('wid', 'uid', 'severity', 'type', 'timestamp', 'message', 'variables', 'link')) @@ -96,7 +98,9 @@ function dblog_top($type) { $count_query->addExpression('COUNT(DISTINCT(message))'); $count_query->condition('type', $type); - $query = db_select('watchdog', 'w')->extend('PagerDefault')->extend('TableSort'); + $query = db_select('watchdog', 'w') + ->extend('Drupal\Core\Database\Query\PagerSelectExtender') + ->extend('TableSort'); $query->addExpression('COUNT(wid)', 'count'); $query = $query ->fields('w', array('message', 'variables')) diff --git a/core/modules/entity/lib/Drupal/entity/EntityFieldQuery.php b/core/modules/entity/lib/Drupal/entity/EntityFieldQuery.php index 852dced4176..05f338b6c68 100644 --- a/core/modules/entity/lib/Drupal/entity/EntityFieldQuery.php +++ b/core/modules/entity/lib/Drupal/entity/EntityFieldQuery.php @@ -9,7 +9,7 @@ namespace Drupal\entity; use Drupal\entity\EntityFieldQueryException; use Drupal\Core\Database\Query\Select; -use PagerDefault; +use Drupal\Core\Database\Query\PagerSelectExtender; /** * Retrieves entities matching a given set of conditions. @@ -571,10 +571,10 @@ class EntityFieldQuery { */ public function pager($limit = 10, $element = NULL) { if (!isset($element)) { - $element = PagerDefault::$maxElement++; + $element = PagerSelectExtender::$maxElement++; } - elseif ($element >= PagerDefault::$maxElement) { - PagerDefault::$maxElement = $element + 1; + elseif ($element >= PagerSelectExtender::$maxElement) { + PagerSelectExtender::$maxElement = $element + 1; } $this->pager = array( diff --git a/core/modules/forum/forum.module b/core/modules/forum/forum.module index 28e7f1786cb..25a4369363a 100644 --- a/core/modules/forum/forum.module +++ b/core/modules/forum/forum.module @@ -893,7 +893,9 @@ function forum_get_topics($tid, $sortby, $forum_per_page) { } } - $query = db_select('forum_index', 'f')->extend('PagerDefault')->extend('TableSort'); + $query = db_select('forum_index', 'f') + ->extend('Drupal\Core\Database\Query\PagerSelectExtender') + ->extend('TableSort'); $query->fields('f'); $query ->condition('f.tid', $tid) diff --git a/core/modules/locale/locale.pages.inc b/core/modules/locale/locale.pages.inc index 3b2d2abc9a3..aaabec72a30 100644 --- a/core/modules/locale/locale.pages.inc +++ b/core/modules/locale/locale.pages.inc @@ -75,7 +75,9 @@ function _locale_translate_seek() { $limit_language = $query['language']; } - $sql_query = $sql_query->extend('PagerDefault')->limit(50); + $sql_query = $sql_query + ->extend('Drupal\Core\Database\Query\PagerSelectExtender') + ->limit(50); $locales = $sql_query->execute(); $header = array(t('String'), t('Context'), ($limit_language) ? t('Language') : t('Languages'), array('data' => t('Operations'), 'colspan' => '2')); diff --git a/core/modules/node/node.admin.inc b/core/modules/node/node.admin.inc index ac362e82324..c933daaa2dc 100644 --- a/core/modules/node/node.admin.inc +++ b/core/modules/node/node.admin.inc @@ -447,7 +447,9 @@ function node_admin_nodes() { } $header['operations'] = array('data' => t('Operations')); - $query = db_select('node', 'n')->extend('PagerDefault')->extend('TableSort'); + $query = db_select('node', 'n') + ->extend('Drupal\Core\Database\Query\PagerSelectExtender') + ->extend('TableSort'); node_build_filter_query($query); if (!user_access('bypass node access')) { diff --git a/core/modules/node/node.module b/core/modules/node/node.module index d2d4bad5149..671d0f09922 100644 --- a/core/modules/node/node.module +++ b/core/modules/node/node.module @@ -1519,7 +1519,9 @@ function node_search_admin() { */ function node_search_execute($keys = NULL, $conditions = NULL) { // Build matching conditions - $query = db_select('search_index', 'i', array('target' => 'slave'))->extend('Drupal\search\SearchQuery')->extend('PagerDefault'); + $query = db_select('search_index', 'i', array('target' => 'slave')) + ->extend('Drupal\search\SearchQuery') + ->extend('Drupal\Core\Database\Query\PagerSelectExtender'); $query->join('node', 'n', 'n.nid = i.sid'); $query ->condition('n.status', 1) @@ -2488,7 +2490,7 @@ function node_page_default() { ->condition('status', 1) ->orderBy('sticky', 'DESC') ->orderBy('created', 'DESC') - ->extend('PagerDefault') + ->extend('Drupal\Core\Database\Query\PagerSelectExtender') ->limit(variable_get('default_nodes_main', 10)) ->addTag('node_access'); diff --git a/core/modules/path/path.admin.inc b/core/modules/path/path.admin.inc index a45565ad1c9..a884f9eaeaf 100644 --- a/core/modules/path/path.admin.inc +++ b/core/modules/path/path.admin.inc @@ -27,7 +27,9 @@ function path_admin_overview($keys = NULL) { } $header[] = array('data' => t('Operations')); - $query = db_select('url_alias')->extend('PagerDefault')->extend('TableSort'); + $query = db_select('url_alias') + ->extend('Drupal\Core\Database\Query\PagerSelectExtender') + ->extend('TableSort'); if ($keys) { // Replace wildcards with PDO wildcards. $query->condition('alias', '%' . preg_replace('!\*+!', '%', $keys) . '%', 'LIKE'); diff --git a/core/modules/poll/poll.pages.inc b/core/modules/poll/poll.pages.inc index 15f3ba79055..b04f99ccb05 100644 --- a/core/modules/poll/poll.pages.inc +++ b/core/modules/poll/poll.pages.inc @@ -29,7 +29,7 @@ function poll_page() { ->groupBy('n.title') ->groupBy('p.active') ->groupBy('n.created') - ->extend('PagerDefault') + ->extend('Drupal\Core\Database\Query\PagerSelectExtender') ->limit($polls_per_page) ->addTag('node_access'); $select->setCountQuery($count_select); @@ -56,7 +56,9 @@ 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')->extend('PagerDefault')->extend('TableSort'); + $select = db_select('poll_vote', 'pv') + ->extend('Drupal\Core\Database\Query\PagerSelectExtender') + ->extend('TableSort'); $select->join('poll_choice', 'pc', 'pv.chid = pc.chid'); $select->join('users', 'u', 'pv.uid = u.uid'); $queried_votes = $select diff --git a/core/modules/search/search.api.php b/core/modules/search/search.api.php index cf8192242ed..0f43460697e 100644 --- a/core/modules/search/search.api.php +++ b/core/modules/search/search.api.php @@ -157,8 +157,8 @@ function hook_search_admin() { /** * Execute a search for a set of key words. * - * Use database API with the 'PagerDefault' query extension to perform your - * search. + * Use database API with the 'Drupal\Core\Database\Query\PagerSelectExtender' + * query extension to perform your search. * * If your module uses hook_update_index() and search_index() to index its * items, use table 'search_index' aliased to 'i' as the main table in your @@ -195,7 +195,9 @@ function hook_search_admin() { */ function hook_search_execute($keys = NULL, $conditions = NULL) { // Build matching conditions - $query = db_select('search_index', 'i', array('target' => 'slave'))->extend('Drupal\search\SearchQuery')->extend('PagerDefault'); + $query = db_select('search_index', 'i', array('target' => 'slave')) + ->extend('Drupal\search\SearchQuery') + ->extend('Drupal\Core\Database\Query\PagerSelectExtender'); $query->join('node', 'n', 'n.nid = i.sid'); $query ->condition('n.status', 1) diff --git a/core/modules/statistics/statistics.admin.inc b/core/modules/statistics/statistics.admin.inc index ea608a43c93..84bf60d93ad 100644 --- a/core/modules/statistics/statistics.admin.inc +++ b/core/modules/statistics/statistics.admin.inc @@ -25,7 +25,9 @@ function statistics_recent_hits() { array('data' => t('Operations')) ); - $query = db_select('accesslog', 'a', array('target' => 'slave'))->extend('PagerDefault')->extend('TableSort'); + $query = db_select('accesslog', 'a', array('target' => 'slave')) + ->extend('Drupal\Core\Database\Query\PagerSelectExtender') + ->extend('TableSort'); $query->join('users', 'u', 'a.uid = u.uid'); $query ->fields('a', array('aid', 'timestamp', 'path', 'title', 'uid')) @@ -71,7 +73,9 @@ function statistics_top_pages() { array('data' => t('Total page generation time'), 'field' => 'total_time') ); - $query = db_select('accesslog', 'a', array('target' => 'slave'))->extend('PagerDefault')->extend('TableSort'); + $query = db_select('accesslog', 'a', array('target' => 'slave')) + ->extend('Drupal\Core\Database\Query\PagerSelectExtender') + ->extend('TableSort'); $query->addExpression('COUNT(path)', 'hits'); // MAX(title) avoids having empty node titles which otherwise causes // duplicates in the top pages list. @@ -124,7 +128,9 @@ function statistics_top_visitors() { array('data' => t('Total page generation time'), 'field' => 'total'), array('data' => user_access('block IP addresses') ? t('Operations') : '', 'colspan' => 2), ); - $query = db_select('accesslog', 'a', array('target' => 'slave'))->extend('PagerDefault')->extend('TableSort'); + $query = db_select('accesslog', 'a', array('target' => 'slave')) + ->extend('Drupal\Core\Database\Query\PagerSelectExtender') + ->extend('TableSort'); $query->leftJoin('blocked_ips', 'bl', 'a.hostname = bl.ip'); $query->leftJoin('users', 'u', 'a.uid = u.uid'); @@ -184,7 +190,9 @@ function statistics_top_referrers() { array('data' => t('Url'), 'field' => 'url'), array('data' => t('Last visit'), 'field' => 'last'), ); - $query = db_select('accesslog', 'a')->extend('PagerDefault')->extend('TableSort'); + $query = db_select('accesslog', 'a') + ->extend('Drupal\Core\Database\Query\PagerSelectExtender') + ->extend('TableSort'); $query->addExpression('COUNT(url)', 'hits'); $query->addExpression('MAX(timestamp)', 'last'); diff --git a/core/modules/statistics/statistics.pages.inc b/core/modules/statistics/statistics.pages.inc index 586189aad1b..524d59e51e7 100644 --- a/core/modules/statistics/statistics.pages.inc +++ b/core/modules/statistics/statistics.pages.inc @@ -25,7 +25,9 @@ function statistics_node_tracker() { array('data' => t('User'), 'field' => 'u.name'), array('data' => t('Operations'))); - $query = db_select('accesslog', 'a', array('target' => 'slave'))->extend('PagerDefault')->extend('TableSort'); + $query = db_select('accesslog', 'a', array('target' => 'slave')) + ->extend('Drupal\Core\Database\Query\PagerSelectExtender') + ->extend('TableSort'); $query->join('users', 'u', 'a.uid = u.uid'); $query @@ -79,7 +81,9 @@ function statistics_user_tracker() { array('data' => t('Timestamp'), 'field' => 'timestamp', 'sort' => 'desc'), array('data' => t('Page'), 'field' => 'path'), array('data' => t('Operations'))); - $query = db_select('accesslog', 'a', array('target' => 'slave'))->extend('PagerDefault')->extend('TableSort'); + $query = db_select('accesslog', 'a', array('target' => 'slave')) + ->extend('Drupal\Core\Database\Query\PagerSelectExtender') + ->extend('TableSort'); $query ->fields('a', array('aid', 'timestamp', 'path', 'title')) ->condition('uid', $account->uid) diff --git a/core/modules/system/system.admin.inc b/core/modules/system/system.admin.inc index a31e278483c..626bf70e617 100644 --- a/core/modules/system/system.admin.inc +++ b/core/modules/system/system.admin.inc @@ -2921,7 +2921,9 @@ function system_actions_manage() { array('data' => t('Label'), 'field' => 'label'), array('data' => $instances_present ? t('Operations') : '', 'colspan' => '2') ); - $query = db_select('actions')->extend('PagerDefault')->extend('TableSort'); + $query = db_select('actions') + ->extend('Drupal\Core\Database\Query\PagerSelectExtender') + ->extend('TableSort'); $result = $query ->fields('actions') ->limit(50) diff --git a/core/modules/system/tests/database.test b/core/modules/system/tests/database.test index 889a30ced70..ef0807be301 100644 --- a/core/modules/system/tests/database.test +++ b/core/modules/system/tests/database.test @@ -2087,7 +2087,7 @@ class DatabaseSelectComplexTestCase extends DatabaseTestCase { function testHavingCountQuery() { $query = db_select('test') - ->extend('PagerDefault') + ->extend('Drupal\Core\Database\Query\PagerSelectExtender') ->groupBy('age') ->having('age + 1 > 0'); $query->addField('test', 'age'); @@ -2352,7 +2352,8 @@ class DatabaseSelectPagerDefaultTestCase extends DatabaseTestCase { * This is a regression test for #467984. */ function testInnerPagerQuery() { - $query = db_select('test', 't')->extend('PagerDefault'); + $query = db_select('test', 't') + ->extend('Drupal\Core\Database\Query\PagerSelectExtender'); $query ->fields('t', array('age')) ->orderBy('age') @@ -2373,7 +2374,8 @@ class DatabaseSelectPagerDefaultTestCase extends DatabaseTestCase { * This is a regression test for #467984. */ function testHavingPagerQuery() { - $query = db_select('test', 't')->extend('PagerDefault'); + $query = db_select('test', 't') + ->extend('Drupal\Core\Database\Query\PagerSelectExtender'); $query ->fields('t', array('name')) ->orderBy('name') @@ -2393,7 +2395,8 @@ class DatabaseSelectPagerDefaultTestCase extends DatabaseTestCase { function testElementNumbers() { $_GET['page'] = '3, 2, 1, 0'; - $name = db_select('test', 't')->extend('PagerDefault') + $name = db_select('test', 't') + ->extend('Drupal\Core\Database\Query\PagerSelectExtender') ->element(2) ->fields('t', array('name')) ->orderBy('age') @@ -2404,7 +2407,8 @@ class DatabaseSelectPagerDefaultTestCase extends DatabaseTestCase { // Setting an element smaller than the previous one // should not overwrite the pager $maxElement with a smaller value. - $name = db_select('test', 't')->extend('PagerDefault') + $name = db_select('test', 't') + ->extend('Drupal\Core\Database\Query\PagerSelectExtender') ->element(1) ->fields('t', array('name')) ->orderBy('age') @@ -2413,7 +2417,8 @@ class DatabaseSelectPagerDefaultTestCase extends DatabaseTestCase { ->fetchField(); $this->assertEqual($name, 'George', t('Pager query #2 with a specified element ID returned the correct results.')); - $name = db_select('test', 't')->extend('PagerDefault') + $name = db_select('test', 't') + ->extend('Drupal\Core\Database\Query\PagerSelectExtender') ->fields('t', array('name')) ->orderBy('age') ->limit(1) diff --git a/core/modules/system/tests/modules/database_test/database_test.module b/core/modules/system/tests/modules/database_test/database_test.module index 0ab51d80747..f248e5a0082 100644 --- a/core/modules/system/tests/modules/database_test/database_test.module +++ b/core/modules/system/tests/modules/database_test/database_test.module @@ -105,7 +105,9 @@ function database_test_even_pager_query($limit) { ->orderBy('age'); // This should result in 2 pages of results. - $query = $query->extend('PagerDefault')->limit($limit); + $query = $query + ->extend('Drupal\Core\Database\Query\PagerSelectExtender') + ->limit($limit); $names = $query->execute()->fetchCol(); @@ -129,7 +131,9 @@ function database_test_odd_pager_query($limit) { ->orderBy('pid'); // This should result in 4 pages of results. - $query = $query->extend('PagerDefault')->limit($limit); + $query = $query + ->extend('Drupal\Core\Database\Query\PagerSelectExtender') + ->limit($limit); $names = $query->execute()->fetchCol(); @@ -213,7 +217,9 @@ function database_test_theme_tablesort($form, &$form_state) { $count_query = clone $query; $count_query->addExpression('COUNT(u.uid)'); - $query = $query->extend('PagerDefault')->extend('TableSort'); + $query = $query + ->extend('Drupal\Core\Database\Query\PagerSelectExtender') + ->extend('TableSort'); $query ->fields('u', array('uid', 'name', 'status', 'created', 'access')) ->limit(50) diff --git a/core/modules/taxonomy/taxonomy.module b/core/modules/taxonomy/taxonomy.module index b536b080384..4778f84d2f5 100644 --- a/core/modules/taxonomy/taxonomy.module +++ b/core/modules/taxonomy/taxonomy.module @@ -233,7 +233,7 @@ function taxonomy_select_nodes($tid, $pager = TRUE, $limit = FALSE, $order = arr $count_query = clone $query; $count_query->addExpression('COUNT(t.nid)'); - $query = $query->extend('PagerDefault'); + $query = $query->extend('Drupal\Core\Database\Query\PagerSelectExtender'); if ($limit !== FALSE) { $query = $query->limit($limit); } diff --git a/core/modules/tracker/tracker.pages.inc b/core/modules/tracker/tracker.pages.inc index 30583be3656..3f9728d990a 100644 --- a/core/modules/tracker/tracker.pages.inc +++ b/core/modules/tracker/tracker.pages.inc @@ -19,7 +19,8 @@ */ function tracker_page($account = NULL, $set_title = FALSE) { if ($account) { - $query = db_select('tracker_user', 't')->extend('PagerDefault'); + $query = db_select('tracker_user', 't') + ->extend('Drupal\Core\Database\Query\PagerSelectExtender'); $query->condition('t.uid', $account->uid); if ($set_title) { @@ -30,7 +31,8 @@ function tracker_page($account = NULL, $set_title = FALSE) { } } else { - $query = db_select('tracker_node', 't', array('target' => 'slave'))->extend('PagerDefault'); + $query = db_select('tracker_node', 't', array('target' => 'slave')) + ->extend('Drupal\Core\Database\Query\PagerSelectExtender'); } // This array acts as a placeholder for the data selected later diff --git a/core/modules/user/user.admin.inc b/core/modules/user/user.admin.inc index c65883ace6b..50d86b063bf 100644 --- a/core/modules/user/user.admin.inc +++ b/core/modules/user/user.admin.inc @@ -158,7 +158,9 @@ function user_admin_account() { $count_query = clone $query; $count_query->addExpression('COUNT(u.uid)'); - $query = $query->extend('PagerDefault')->extend('TableSort'); + $query = $query + ->extend('Drupal\Core\Database\Query\PagerSelectExtender') + ->extend('TableSort'); $query ->fields('u', array('uid', 'name', 'status', 'created', 'access')) ->limit(50) diff --git a/core/modules/user/user.module b/core/modules/user/user.module index d023f50af48..80077216033 100644 --- a/core/modules/user/user.module +++ b/core/modules/user/user.module @@ -641,7 +641,8 @@ function user_search_execute($keys = NULL, $conditions = NULL) { $find = array(); // Replace wildcards with MySQL/PostgreSQL wildcards. $keys = preg_replace('!\*+!', '%', $keys); - $query = db_select('users')->extend('PagerDefault'); + $query = db_select('users') + ->extend('Drupal\Core\Database\Query\PagerSelectExtender'); $query->fields('users', array('uid')); if (user_access('administer users')) { // Administrators can also search in the otherwise private email field.