r74567 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r74566‎ | r74567 | r74568 >
Date:20:33, 9 October 2010
Author:reedy
Status:deferred
Tags:
Comment:
Reapply r65496
Modified paths:
  • /branches/querypage-work2/extensions/ProofreadPage/ProofreadPage.php (modified) (history)
  • /branches/querypage-work2/extensions/ProofreadPage/SpecialProofreadPages.php (modified) (history)

Diff [purge]

Index: branches/querypage-work2/extensions/ProofreadPage/SpecialProofreadPages.php
@@ -4,18 +4,9 @@
55 * @ingroup SpecialPage
66 */
77
8 -if ( !defined( 'MEDIAWIKI' ) ) {
9 - die( 1 );
10 -}
11 -
12 -global $IP;
13 -require_once "$IP/includes/QueryPage.php";
14 -
15 -class ProofreadPages extends SpecialPage {
16 -
 8+class IndexPagesPage extends QueryPage {
179 public function __construct() {
18 - parent::__construct( 'IndexPages' );
19 - wfLoadExtensionMessages( 'ProofreadPage' );
 10+ SpecialPage::__construct( 'IndexPages' );
2011 $this->index_namespace = preg_quote( wfMsgForContent( 'proofreadpage_index_namespace' ), '/' );
2112 }
2213
@@ -52,23 +43,39 @@
5344 }
5445 }
5546 }
56 - $cnl = new ProofreadPagesQuery( $searchList, $searchTerm );
57 - $cnl->doQuery( $offset, $limit );
 47+ parent::execute( $parameters );
5848 }
59 -}
 49+ public function getQueryInfo() {
 50+ $conds = array();
 51+ if ( $this->searchTerm ) {
 52+ if ( $this->searchList ) {
 53+ $index_namespace = pr_index_ns();
 54+ $index_ns_index = MWNamespace::getCanonicalIndex( strtolower( $index_namespace ) );
 55+ $conds = array( 'page_namespace' => $index_ns_index, 'page_title' => $this->searchList );
 56+ } else {
 57+ $conds = array( 'false' ); // FIXME: This is ugly
 58+ }
 59+ }
 60+ return array(
 61+ 'tables' => array( 'pr_index', 'page' ),
 62+ 'fields' => array( 'page_title AS title', 'pr_count',
 63+ 'pr_q0', 'pr_q1', 'pr_q2' ,'pr_q3', 'pr_q4' ),
 64+ 'conds' => $conds,
 65+ 'options' => array(),
 66+ 'join_conds' => array( 'page' => array( 'LEFT JOIN', 'page_id=pr_page_id' ) )
 67+ );
 68+ }
6069
61 -class ProofreadPagesQuery extends QueryPage {
62 - function __construct( $searchList, $searchTerm ) {
63 - $this->searchList = $searchList;
64 - $this->searchTerm = $searchTerm;
65 - $this->index_namespace = preg_quote( wfMsgForContent( 'proofreadpage_index_namespace' ), '/' );
 70+ public function getOrderFields() {
 71+ return array( '2*pr_q4+pr_q3' ); // FIXME: This causes a filesort
6672 }
6773
68 - function getName() {
69 - return 'IndexPages';
 74+ public function sortDescending() {
 75+ return true;
7076 }
7177
7278 function isExpensive() {
 79+ // FIXME: the query does filesort, so we're kinda lying here right now
7380 return false;
7481 }
7582
@@ -76,46 +83,6 @@
7784 return false;
7885 }
7986
80 - function linkParameters() {
81 - return array( 'key' => $this->searchTerm );
82 - }
83 -
84 - function getSQL() {
85 - $dbr = wfGetDB( DB_SLAVE );
86 - $page = $dbr->tableName( 'page' );
87 - $pr_index = $dbr->tableName( 'pr_index' );
88 -
89 - $query = "SELECT page_title as title,
90 - pr_count,pr_q0,pr_q1,pr_q2,pr_q3,pr_q4
91 - FROM $pr_index LEFT JOIN $page ON page_id = pr_page_id";
92 -
93 - if( $this->searchTerm ) {
94 - if( $this->searchList ) {
95 - $index_ns_index = MWNamespace::getCanonicalIndex( strtolower( $this->index_namespace ) );
96 - $querylist = '';
97 - foreach( $this->searchList as $item ) {
98 - if( $querylist ) {
99 - $querylist .= ', ';
100 - }
101 - $querylist .= "'" . $dbr->strencode( $item ). "'";
102 - }
103 - $query .= " WHERE page_namespace=$index_ns_index AND page_title IN ($querylist)";
104 - } else {
105 - # The SQL query is complete
106 - }
107 - }
108 - return $query;
109 - }
110 -
111 - function getOrder() {
112 - return ' ORDER BY 2*pr_q4+pr_q3 ' .
113 - ( $this->sortDescending() ? 'DESC' : '' );
114 - }
115 -
116 - function sortDescending() {
117 - return true;
118 - }
119 -
12087 function formatResult( $skin, $result ) {
12188 global $wgLang;
12289
Index: branches/querypage-work2/extensions/ProofreadPage/ProofreadPage.php
@@ -37,9 +37,10 @@
3838 );
3939
4040 # special page
41 -$wgAutoloadClasses['ProofreadPages'] = $dir . 'SpecialProofreadPages.php';
42 -$wgSpecialPages['IndexPages'] = 'ProofreadPages';
 41+$wgAutoloadClasses['IndexPagesPage'] = $dir . 'SpecialProofreadPages.php';
 42+$wgSpecialPages['IndexPages'] = 'IndexPagesPage';
4343 $wgSpecialPageGroups['IndexPages'] = 'pages';
 44+$wgQueryPages['IndexPagesPage'] = 'IndexPages';
4445
4546 # special page
4647 $wgAutoloadClasses['PagesWithoutScans'] = $dir . 'SpecialPagesWithoutScans.php';

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r65496querypage-work2: Rewrite Special:IndexPages in extensions/ProofreadPage as a ...catrope22:00, 23 April 2010

Status & tagging log