r50476 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r50475‎ | r50476 | r50477 >
Date:12:19, 11 May 2009
Author:catrope
Status:deferred
Tags:
Comment:
querypage-work: Starting to convert querypages to SpecialPage subclasses; WIP
Modified paths:
  • /branches/querypage-work/phase3/includes/QueryPage.php (modified) (history)
  • /branches/querypage-work/phase3/includes/specials/SpecialPopularpages.php (modified) (history)
  • /branches/querypage-work/phase3/includes/specials/SpecialShortpages.php (modified) (history)
  • /branches/querypage-work/phase3/includes/specials/SpecialUnusedimages.php (modified) (history)
  • /branches/querypage-work/phase3/includes/specials/SpecialWithoutinterwiki.php (modified) (history)

Diff [purge]

Index: branches/querypage-work/phase3/includes/specials/SpecialPopularpages.php
@@ -23,8 +23,7 @@
2424 function getQueryInfo() {
2525 return array (
2626 'tables' => array( 'page' ),
27 - 'fields' => array( "'{$this->getName()}' AS type",
28 - 'page_namespace AS namespace',
 27+ 'fields' => array( 'page_namespace AS namespace',
2928 'page_title AS title',
3029 'page_counter AS value'),
3130 'conds' => array( 'page_is_redirect' => 0,
Index: branches/querypage-work/phase3/includes/specials/SpecialShortpages.php
@@ -39,6 +39,15 @@
4040 );
4141 }
4242
 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+
4352 function preprocessResults( $db, $res ) {
4453 # There's no point doing a batch check if we aren't caching results;
4554 # 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 @@
6767 'LEFT JOIN', 'll_from = page_id' ) )
6868 );
6969 if ( $this->prefix ) {
 70+ // TODO: Include namespace so this is indexed
7071 $dbr = wfGetDb( DB_SLAVE );
7172 $encPrefix = $dbr->escapeLike( $this->prefix );
7273 $query['conds'][] = "page_title LIKE '{$encPrefix}%'";
Index: branches/querypage-work/phase3/includes/specials/SpecialUnusedimages.php
@@ -37,6 +37,7 @@
3838 );
3939 if ( $wgCountCategorizedImagesAsUsed ) {
4040 // Order is significant
 41+ // TODO: Revise query to LEFT JOIN page instead
4142 $retval['tables'] = array ( 'page', 'categorylinks',
4243 'imagelinks', 'image' );
4344 $retval['conds']['page_namespace'] = NS_FILE;
Index: branches/querypage-work/phase3/includes/QueryPage.php
@@ -60,7 +60,7 @@
6161 * subclasses derive from it.
6262 * @ingroup SpecialPage
6363 */
64 -abstract class QueryPage {
 64+abstract class QueryPage extends SpecialPage {
6565 /**
6666 * Whether or not we want plain listoutput rather than an ordered list
6767 *
@@ -77,6 +77,18 @@
7878 var $limit = 0;
7979
8080 /**
 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+ /**
8193 * A mutator for $this->listoutput;
8294 *
8395 * @param bool $bool
@@ -90,8 +102,7 @@
91103 * specified in SpecialPage.php and in Language.php as a language
92104 * message param.
93105 */
94 - function getName() {
95 - return '';
 106+ abstract function getName();
96107 }
97108
98109 /**
@@ -331,6 +342,13 @@
332343 );
333344 return $dbr->resultObject( $res );
334345 }
 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+ }
335353
336354 /**
337355 * Fetch the query results from the query cache
@@ -360,16 +378,11 @@
361379 /**
362380 * This is the actual workhorse. It does everything needed to make a
363381 * 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"?
368382 */
369 - function doQuery( $offset, $limit, $shownavigation=true ) {
 383+ function execute( $par ) {
370384 global $wgUser, $wgOut, $wgLang, $wgContLang;
371385
372 - $this->offset = $offset;
373 - $this->limit = $limit;
 386+ list( $this->offset, $this->limit ) = wfCheckLimits();
374387
375388 $sname = $this->getName();
376389 $fname = get_class($this) . '::doQuery';
@@ -377,6 +390,7 @@
378391
379392 $wgOut->setSyndicated( $this->isSyndicated() );
380393
 394+ // TODO: Use doQuery()
381395 //$res = null;
382396 if ( !$this->isCached() ) {
383397 $res = $this->reallyDoQuery( $limit, $offset );
@@ -416,7 +430,7 @@
417431 $wgOut->addHTML( XML::openElement( 'div', array('class' => 'mw-spcontent') ) );
418432
419433 # Top header and navigation
420 - if( $shownavigation ) {
 434+ if( $this->shownavigation ) {
421435 $wgOut->addHTML( $this->getPageHeader() );
422436 if( $num > 0 ) {
423437 $wgOut->addHTML( '<p>' . wfShowingResults( $offset, $num ) . '</p>' );

Follow-up revisions

RevisionCommit summaryAuthorDate
r65324querypage-work2: Merge r50476reedy14:26, 20 April 2010

Status & tagging log