r78723 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r78722‎ | r78723 | r78724 >
Date:19:45, 21 December 2010
Author:catrope
Status:deferred
Tags:
Comment:
Fix misc snafus in SpecialProofreadPages:
* Some code seems to expect $searchTerm is a property, so make it one
* Remove now-broken getOrder() override, add value field to produce the same effect
* Explicitly declare $index_namespace as a property
Modified paths:
  • /branches/querypage-work2/extensions/ProofreadPage/SpecialProofreadPages.php (modified) (history)

Diff [purge]

Index: branches/querypage-work2/extensions/ProofreadPage/SpecialProofreadPages.php
@@ -5,7 +5,8 @@
66 */
77
88 class ProofreadPages extends QueryPage {
9 -
 9+ protected $index_namespace, $searchTerm;
 10+
1011 public function __construct( $name = 'IndexPages' ) {
1112 parent::__construct( $name );
1213 $this->index_namespace = wfMsgForContent( 'proofreadpage_index_namespace' );
@@ -18,25 +19,25 @@
1920 list( $limit, $offset ) = wfCheckLimits();
2021 $wgOut->addWikiText( wfMsgForContentNoTrans( 'proofreadpage_specialpage_text' ) );
2122 $searchList = array();
22 - $searchTerm = $wgRequest->getText( 'key' );
 23+ $this->searchTerm = $wgRequest->getText( 'key' );
2324 if( !$wgDisableTextSearch ) {
2425 $wgOut->addHTML(
2526 Xml::openElement( 'form' ) .
2627 Xml::openElement( 'fieldset' ) .
2728 Xml::element( 'legend', null, wfMsg( 'proofreadpage_specialpage_legend' ) ) .
28 - Xml::input( 'key', 20, $searchTerm ) . ' ' .
 29+ Xml::input( 'key', 20, $this->searchTerm ) . ' ' .
2930 Xml::submitButton( wfMsg( 'ilsubmit' ) ) .
3031 Xml::closeElement( 'fieldset' ) .
3132 Xml::closeElement( 'form' )
3233 );
33 - if( $searchTerm ) {
 34+ if( $this->searchTerm ) {
3435 $index_namespace = $this->index_namespace;
3536 $index_ns_index = MWNamespace::getCanonicalIndex( strtolower( $index_namespace ) );
3637 $searchEngine = SearchEngine::create();
3738 $searchEngine->setLimitOffset( $limit, $offset );
3839 $searchEngine->setNamespaces( array( $index_ns_index ) );
3940 $searchEngine->showRedirects = false;
40 - $textMatches = $searchEngine->searchText( $searchTerm );
 41+ $textMatches = $searchEngine->searchText( $this->searchTerm );
4142 $escIndex = preg_quote( $index_namespace, '/' );
4243 while( $result = $textMatches->next() ) {
4344 if ( preg_match( "/^$escIndex:(.*)$/", $result->getTitle(), $m ) ) {
@@ -74,7 +75,7 @@
7576 }
7677 return array(
7778 'tables' => array( 'pr_index', 'page' ),
78 - 'fields' => array( 'page_title AS title', 'pr_count',
 79+ 'fields' => array( 'page_title AS title', '2*pr_q4+pr_q3 AS value', 'pr_count',
7980 'pr_q0', 'pr_q1', 'pr_q2' ,'pr_q3', 'pr_q4' ),
8081 'conds' => $conds,
8182 'options' => array(),
@@ -82,11 +83,6 @@
8384 );
8485 }
8586
86 - function getOrder() {
87 - return ' ORDER BY 2*pr_q4+pr_q3 ' .
88 - ( $this->sortDescending() ? 'DESC' : '' ); // FIXME: This causes a filesort
89 - }
90 -
9187 function sortDescending() {
9288 return true;
9389 }

Status & tagging log