+ $res = $dbr->select(
+ array( 'page', 'categorylinks', 'category' ),
+ array( 'page_id', 'page_title', 'page_namespace', 'page_len',
+ 'page_is_redirect', 'cl_sortkey', 'cat_id', 'cat_title',
+ 'cat_subcats', 'cat_pages', 'cat_files', 'cl_sortkey_prefix' ),
+ array( 'cl_to' => $this->title->getDBkey() ) + $extraConds,
+ __METHOD__,
+ array(
+ 'USE INDEX' => array( 'categorylinks' => 'cl_sortkey' ),
+ 'LIMIT' => $this->limit + 1,
+ 'ORDER BY' => $this->flip[$type] ? 'cl_sortkey DESC' : 'cl_sortkey',
+ ),
+ array(
+ 'categorylinks' => array( 'INNER JOIN', 'cl_from = page_id' ),
+ 'category' => array( 'LEFT JOIN', 'cat_title = page_title AND page_namespace = ' . NS_CATEGORY )
+ )
+ );
+
+ $count = 0;
+ foreach ( $res as $row ) {
+ $title = Title::newFromRow( $row );
+ $rawSortkey = $title->getCategorySortkey( $row->cl_sortkey_prefix );
+
+ if ( ++$count > $this->limit ) {
+ # We've reached the one extra which shows that there
+ # are additional pages to be had. Stop here...
+ $this->nextPage[$type] = $rawSortkey;
+ break;
+ }