Index: branches/querypage-work2/extensions/ProofreadPage/SpecialPagesWithoutScans.php |
— | — | @@ -23,30 +23,13 @@ |
24 | 24 | * Special page that lists the texts that have no transclusions |
25 | 25 | * Pages in MediaWiki:Proofreadpage_notnaked_category are excluded. |
26 | 26 | */ |
27 | | -class PagesWithoutScans extends SpecialPage { |
| 27 | +class PagesWithoutScans extends QueryPage { |
28 | 28 | |
29 | | - public function __construct() { |
30 | | - parent::__construct( 'PagesWithoutScans' ); |
| 29 | + function __construct( $name = 'PagesWithoutScans' ) { |
| 30 | + parent::__construct( $name ); |
| 31 | + $this->page_namespace = wfMsgForContent( 'proofreadpage_namespace' ); |
31 | 32 | } |
32 | 33 | |
33 | | - public function execute( $parameters ) { |
34 | | - $this->setHeaders(); |
35 | | - list( $limit, $offset ) = wfCheckLimits(); |
36 | | - $cnl = new PagesWithoutScansQuery(); |
37 | | - $cnl->doQuery( $offset, $limit ); |
38 | | - } |
39 | | -} |
40 | | - |
41 | | -class PagesWithoutScansQuery extends QueryPage { |
42 | | - |
43 | | - function __construct() { |
44 | | - $this->page_namespace = preg_quote( wfMsgForContent( 'proofreadpage_namespace' ), '/' ); |
45 | | - } |
46 | | - |
47 | | - function getName() { |
48 | | - return 'PagesWithoutScans'; |
49 | | - } |
50 | | - |
51 | 34 | function isExpensive() { |
52 | 35 | return true; |
53 | 36 | } |
— | — | @@ -55,9 +38,9 @@ |
56 | 39 | return false; |
57 | 40 | } |
58 | 41 | |
59 | | - /* |
60 | | - * return a clause with the list of disambiguation templates. |
61 | | - * this function was copied verbatim from specials/SpecialDisambiguations.php |
| 42 | + /** |
| 43 | + * Return a clause with the list of disambiguation templates. |
| 44 | + * This function was copied verbatim from specials/SpecialDisambiguations.php |
62 | 45 | */ |
63 | 46 | function disambiguation_templates( $dbr ) { |
64 | 47 | $dMsgText = wfMsgForContent('disambiguationspage'); |
— | — | @@ -92,30 +75,47 @@ |
93 | 76 | } |
94 | 77 | return $linkBatch->constructSet( 'tl', $dbr ); |
95 | 78 | } |
96 | | - |
97 | | - function getSQL() { |
| 79 | + |
| 80 | + function getQueryInfo() { |
98 | 81 | $dbr = wfGetDB( DB_SLAVE ); |
99 | | - $page = $dbr->tableName( 'page' ); |
100 | | - $templatelinks = $dbr->tableName( 'templatelinks' ); |
101 | | - $forceindex = $dbr->useIndexClause( 'page_len' ); |
102 | 82 | $page_ns_index = MWNamespace::getCanonicalIndex( strtolower( $this->page_namespace ) ); |
103 | | - |
104 | | - /* SQL clause to exclude pages with scans */ |
105 | | - $pages_with_scans = "( SELECT DISTINCT tl_from FROM $templatelinks LEFT JOIN $page ON page_id=tl_from WHERE tl_namespace=$page_ns_index AND page_namespace=" . NS_MAIN . " ) "; |
106 | | - |
107 | | - /* Exclude disambiguation pages too */ |
| 83 | + |
| 84 | + // Construct subqueries |
| 85 | + $pagesWithScansSubquery = $dbr->selectSQLText( |
| 86 | + array( 'templatelinks', 'page' ), |
| 87 | + 'DISTINCT tl_from', |
| 88 | + array( |
| 89 | + 'page_id=tl_from', |
| 90 | + 'tl_namespace' => $page_ns_index, |
| 91 | + 'page_namespace' => NS_MAIN |
| 92 | + ) |
| 93 | + ); |
| 94 | + |
| 95 | + // Exclude disambiguation pages too |
108 | 96 | $dt = $this->disambiguation_templates( $dbr ); |
109 | | - $disambiguation_pages = "( SELECT page_id FROM $page LEFT JOIN $templatelinks ON page_id=tl_from WHERE page_namespace=" . NS_MAIN . " AND " . $dt . " )"; |
110 | | - |
111 | | - $sql = "SELECT page_namespace as namespace, |
112 | | - page_title as title, |
113 | | - page_len AS value |
114 | | - FROM $page $forceindex |
115 | | - WHERE page_namespace=" . NS_MAIN . " AND page_is_redirect=0 |
116 | | - AND page_id NOT IN $pages_with_scans |
117 | | - AND page_id NOT IN $disambiguation_pages"; |
118 | | - |
119 | | - return $sql; |
| 97 | + $disambigPagesSubquery = $dbr->selectSQLText( |
| 98 | + array( 'page', 'templatelinks' ), |
| 99 | + 'page_id', |
| 100 | + array( |
| 101 | + 'page_id=tl_from', |
| 102 | + 'page_namespace' => NS_MAIN, |
| 103 | + $dt |
| 104 | + ) |
| 105 | + ); |
| 106 | + |
| 107 | + return array( |
| 108 | + 'tables' => 'page', |
| 109 | + 'fields' => array( |
| 110 | + 'page_namespace AS namespace', |
| 111 | + 'page_title AS title', |
| 112 | + 'page_len AS value' ), |
| 113 | + 'conds' => array( |
| 114 | + 'page_namespace' => NS_MAIN, |
| 115 | + 'page_is_redirect' => 0, |
| 116 | + "page_id NOT IN ($pagesWithScansSubquery)", |
| 117 | + "page_id NOT IN ($disambigPagesSubquery)" ), |
| 118 | + 'options' => array( 'USE INDEX' => 'page_len' ) |
| 119 | + ); |
120 | 120 | } |
121 | 121 | |
122 | 122 | function sortDescending() { |