Index: branches/querypage-work/phase3/includes/specials/SpecialPopularpages.php |
— | — | @@ -23,8 +23,7 @@ |
24 | 24 | function getQueryInfo() { |
25 | 25 | return array ( |
26 | 26 | 'tables' => array( 'page' ), |
27 | | - 'fields' => array( "'{$this->getName()}' AS type", |
28 | | - 'page_namespace AS namespace', |
| 27 | + 'fields' => array( 'page_namespace AS namespace', |
29 | 28 | 'page_title AS title', |
30 | 29 | 'page_counter AS value'), |
31 | 30 | 'conds' => array( 'page_is_redirect' => 0, |
Index: branches/querypage-work/phase3/includes/specials/SpecialShortpages.php |
— | — | @@ -39,6 +39,15 @@ |
40 | 40 | ); |
41 | 41 | } |
42 | 42 | |
| 43 | + function getOrderFields() { |
| 44 | + // For some crazy reason ordering by a constant |
| 45 | + // causes a filesort |
| 46 | + if( count( MWNamespace::getContentNamespaces() ) > 1 ) |
| 47 | + return array( 'page_namespace', 'page_title' ); |
| 48 | + else |
| 49 | + return array( 'page_title' ); |
| 50 | + } |
| 51 | + |
43 | 52 | function preprocessResults( $db, $res ) { |
44 | 53 | # There's no point doing a batch check if we aren't caching results; |
45 | 54 | # the page must exist for it to have been pulled out of the table |
Index: branches/querypage-work/phase3/includes/specials/SpecialWithoutinterwiki.php |
— | — | @@ -66,6 +66,7 @@ |
67 | 67 | 'LEFT JOIN', 'll_from = page_id' ) ) |
68 | 68 | ); |
69 | 69 | if ( $this->prefix ) { |
| 70 | + // TODO: Include namespace so this is indexed |
70 | 71 | $dbr = wfGetDb( DB_SLAVE ); |
71 | 72 | $encPrefix = $dbr->escapeLike( $this->prefix ); |
72 | 73 | $query['conds'][] = "page_title LIKE '{$encPrefix}%'"; |
Index: branches/querypage-work/phase3/includes/specials/SpecialUnusedimages.php |
— | — | @@ -37,6 +37,7 @@ |
38 | 38 | ); |
39 | 39 | if ( $wgCountCategorizedImagesAsUsed ) { |
40 | 40 | // Order is significant |
| 41 | + // TODO: Revise query to LEFT JOIN page instead |
41 | 42 | $retval['tables'] = array ( 'page', 'categorylinks', |
42 | 43 | 'imagelinks', 'image' ); |
43 | 44 | $retval['conds']['page_namespace'] = NS_FILE; |
Index: branches/querypage-work/phase3/includes/QueryPage.php |
— | — | @@ -60,7 +60,7 @@ |
61 | 61 | * subclasses derive from it. |
62 | 62 | * @ingroup SpecialPage |
63 | 63 | */ |
64 | | -abstract class QueryPage { |
| 64 | +abstract class QueryPage extends SpecialPage { |
65 | 65 | /** |
66 | 66 | * Whether or not we want plain listoutput rather than an ordered list |
67 | 67 | * |
— | — | @@ -77,6 +77,18 @@ |
78 | 78 | var $limit = 0; |
79 | 79 | |
80 | 80 | /** |
| 81 | + * Wheter to show prev/next links |
| 82 | + */ |
| 83 | + var $shownavigation = true; |
| 84 | + |
| 85 | + /** |
| 86 | + * Constructor |
| 87 | + */ |
| 88 | + public function __construct() { |
| 89 | + parent::__construct( $this->getName() ); |
| 90 | + } |
| 91 | + |
| 92 | + /** |
81 | 93 | * A mutator for $this->listoutput; |
82 | 94 | * |
83 | 95 | * @param bool $bool |
— | — | @@ -90,8 +102,7 @@ |
91 | 103 | * specified in SpecialPage.php and in Language.php as a language |
92 | 104 | * message param. |
93 | 105 | */ |
94 | | - function getName() { |
95 | | - return ''; |
| 106 | + abstract function getName(); |
96 | 107 | } |
97 | 108 | |
98 | 109 | /** |
— | — | @@ -331,6 +342,13 @@ |
332 | 343 | ); |
333 | 344 | return $dbr->resultObject( $res ); |
334 | 345 | } |
| 346 | + |
| 347 | + function doQuery( $limit, $offset = false ) { |
| 348 | + if( $this->isCached() ) |
| 349 | + return $this->fetchFromCache( $limit, $offset ); |
| 350 | + else |
| 351 | + return $this->reallyDoQuery( $limit, $offset ); |
| 352 | + } |
335 | 353 | |
336 | 354 | /** |
337 | 355 | * Fetch the query results from the query cache |
— | — | @@ -360,16 +378,11 @@ |
361 | 379 | /** |
362 | 380 | * This is the actual workhorse. It does everything needed to make a |
363 | 381 | * real, honest-to-gosh query page. |
364 | | - * |
365 | | - * @param $offset database query offset |
366 | | - * @param $limit database query limit |
367 | | - * @param $shownavigation show navigation like "next 200"? |
368 | 382 | */ |
369 | | - function doQuery( $offset, $limit, $shownavigation=true ) { |
| 383 | + function execute( $par ) { |
370 | 384 | global $wgUser, $wgOut, $wgLang, $wgContLang; |
371 | 385 | |
372 | | - $this->offset = $offset; |
373 | | - $this->limit = $limit; |
| 386 | + list( $this->offset, $this->limit ) = wfCheckLimits(); |
374 | 387 | |
375 | 388 | $sname = $this->getName(); |
376 | 389 | $fname = get_class($this) . '::doQuery'; |
— | — | @@ -377,6 +390,7 @@ |
378 | 391 | |
379 | 392 | $wgOut->setSyndicated( $this->isSyndicated() ); |
380 | 393 | |
| 394 | + // TODO: Use doQuery() |
381 | 395 | //$res = null; |
382 | 396 | if ( !$this->isCached() ) { |
383 | 397 | $res = $this->reallyDoQuery( $limit, $offset ); |
— | — | @@ -416,7 +430,7 @@ |
417 | 431 | $wgOut->addHTML( XML::openElement( 'div', array('class' => 'mw-spcontent') ) ); |
418 | 432 | |
419 | 433 | # Top header and navigation |
420 | | - if( $shownavigation ) { |
| 434 | + if( $this->shownavigation ) { |
421 | 435 | $wgOut->addHTML( $this->getPageHeader() ); |
422 | 436 | if( $num > 0 ) { |
423 | 437 | $wgOut->addHTML( '<p>' . wfShowingResults( $offset, $num ) . '</p>' ); |