Index: branches/querypage-work/phase3/includes/PageQueryPage.php |
— | — | @@ -5,7 +5,7 @@ |
6 | 6 | * |
7 | 7 | * @ingroup SpecialPage |
8 | 8 | */ |
9 | | -class PageQueryPage extends QueryPage { |
| 9 | +abstract class PageQueryPage extends QueryPage { |
10 | 10 | |
11 | 11 | /** |
12 | 12 | * Format the result as a simple link to the page |
Index: branches/querypage-work/phase3/includes/Namespace.php |
— | — | @@ -182,4 +182,23 @@ |
183 | 183 | return !empty( $wgNamespacesWithSubpages[$index] ); |
184 | 184 | } |
185 | 185 | |
| 186 | + /** |
| 187 | + * Get a list of all namespace indices which are considered to contain content |
| 188 | + * |
| 189 | + * If only one content namespace exists, returns that single index (Int) |
| 190 | + * If multiple content namespaces exist, it returns an array of indices |
| 191 | + * |
| 192 | + * @return mixed |
| 193 | + */ |
| 194 | + public static function getContentNamespaces() { |
| 195 | + global $wgContentNamespaces; |
| 196 | + if( empty( $wgContentNamespaces ) ) |
| 197 | + return NS_MAIN; |
| 198 | + // always force NS_MAIN to be part of array (to match the algorithm used by isContent) |
| 199 | + elseif ( !in_array( NS_MAIN, $wgContentNamespaces ) ) |
| 200 | + return array( NS_MAIN ) + $wgContentNamespaces; |
| 201 | + else |
| 202 | + return $wgContentNamespaces; |
| 203 | + |
| 204 | + } |
186 | 205 | } |
Index: branches/querypage-work/phase3/includes/specials/SpecialFewestrevisions.php |
— | — | @@ -32,7 +32,7 @@ |
33 | 33 | 'page_title AS title', |
34 | 34 | 'COUNT(*) AS value', |
35 | 35 | 'page_is_redirect AS redirect' ), |
36 | | - 'conds' => array ( 'page_namespace' => NS_MAIN, |
| 36 | + 'conds' => array ( 'page_namespace' => MWNamespace::getContentNamespaces(), |
37 | 37 | 'page_id = rev_page' ), |
38 | 38 | 'options' => array ( 'HAVING' => 'COUNT(*) > 1', |
39 | 39 | // ^^^ This was probably here to weed out redirects. |
Index: branches/querypage-work/phase3/includes/specials/SpecialDisambiguations.php |
— | — | @@ -129,7 +129,7 @@ |
130 | 130 | 'pl_namespace = p1.page_namespace', |
131 | 131 | 'pl_title = p1.page_title', |
132 | 132 | 'p2.page_id = pl_from', |
133 | | - 'p2.page_namespace' => NS_MAIN ) |
| 133 | + 'p2.page_namespace' => MWNamespace::getContentNamespaces() ) |
134 | 134 | ); |
135 | 135 | } |
136 | 136 | |
Index: branches/querypage-work/phase3/includes/specials/SpecialMostcategories.php |
— | — | @@ -25,7 +25,7 @@ |
26 | 26 | 'page_namespace AS namespace', |
27 | 27 | 'page_title AS title', |
28 | 28 | 'COUNT(*) AS value' ), |
29 | | - 'conds' => array ( 'page_namespace' => NS_MAIN ), |
| 29 | + 'conds' => array ( 'page_namespace' => MWNamespace::getContentNamespaces() ), |
30 | 30 | 'options' => array ( 'HAVING' => 'COUNT(*) > 1', |
31 | 31 | 'GROUP BY' => 'page_namespace, page_title' ), |
32 | 32 | // TODO: test this JOIN |
Index: branches/querypage-work/phase3/includes/specials/SpecialPopularpages.php |
— | — | @@ -20,29 +20,15 @@ |
21 | 21 | } |
22 | 22 | function isSyndicated() { return false; } |
23 | 23 | |
24 | | - function getSQL() { |
25 | | - $dbr = wfGetDB( DB_SLAVE ); |
26 | | - $page = $dbr->tableName( 'page' ); |
27 | | - |
28 | | - $query = |
29 | | - "SELECT 'Popularpages' as type, |
30 | | - page_namespace as namespace, |
31 | | - page_title as title, |
32 | | - page_counter as value |
33 | | - FROM $page "; |
34 | | - $where = |
35 | | - "WHERE page_is_redirect=0 AND page_namespace"; |
36 | | - |
37 | | - global $wgContentNamespaces; |
38 | | - if( empty( $wgContentNamespaces ) ) { |
39 | | - $where .= '='.NS_MAIN; |
40 | | - } else if( count( $wgContentNamespaces ) > 1 ) { |
41 | | - $where .= ' in (' . implode( ', ', $wgContentNamespaces ) . ')'; |
42 | | - } else { |
43 | | - $where .= '='.$wgContentNamespaces[0]; |
44 | | - } |
45 | | - |
46 | | - return $query . $where; |
| 24 | + function getQueryInfo() { |
| 25 | + return array ( |
| 26 | + 'tables' => array( 'page' ), |
| 27 | + 'fields' => array( "'{$this->getName()}' AS type", |
| 28 | + 'page_namespace AS namespace', |
| 29 | + 'page_title AS title', |
| 30 | + 'page_counter AS value'), |
| 31 | + 'conds' => array( 'page_is_redirect' => 0, |
| 32 | + 'page_namespace' => MWNamespace::getContentNamespaces() ) ); |
47 | 33 | } |
48 | 34 | |
49 | 35 | function formatResult( $skin, $result ) { |
Index: branches/querypage-work/phase3/includes/specials/SpecialLonelypages.php |
— | — | @@ -36,7 +36,7 @@ |
37 | 37 | 'page_title AS title', |
38 | 38 | 'page_title AS value' ), |
39 | 39 | 'conds' => array ( 'pl_namespace IS NULL', |
40 | | - 'page_namespace' => NS_MAIN, |
| 40 | + 'page_namespace' => MWNamespace::getContentNamespaces(), |
41 | 41 | 'page_is_redirect' => 0, |
42 | 42 | 'tl_namespace IS NULL' ), |
43 | 43 | // TODO: test this JOIN |
Index: branches/querypage-work/phase3/includes/specials/SpecialUncategorizedpages.php |
— | — | @@ -10,7 +10,7 @@ |
11 | 11 | */ |
12 | 12 | // FIXME: Make $requestedNamespace selectable, unify all subclasses into one |
13 | 13 | class UncategorizedPagesPage extends PageQueryPage { |
14 | | - var $requestedNamespace = NS_MAIN; |
| 14 | + var $requestedNamespace = false; |
15 | 15 | |
16 | 16 | function getName() { |
17 | 17 | return "Uncategorizedpages"; |
— | — | @@ -32,8 +32,10 @@ |
33 | 33 | 'page_namespace AS namespace', |
34 | 34 | 'page_title AS title', |
35 | 35 | 'page_title AS value' ), |
| 36 | + // default for page_namespace is all content namespaces (if requestedNamespace is false) |
| 37 | + // otherwise, page_namespace is requestedNamespace |
36 | 38 | 'conds' => array ( 'cl_from IS NULL', |
37 | | - 'page_namespace' => $this->requestedNamespace, |
| 39 | + 'page_namespace' => ( $this->requestedNamespace!==false ? $this->requestedNamespace : MWNamespace::getContentNamespaces() ), |
38 | 40 | 'page_is_redirect' => 0 ), |
39 | 41 | 'join_conds' => array ( 'categorylinks' => array ( |
40 | 42 | 'LEFT JOIN', 'cl_from = page_id' ) ) |
Index: branches/querypage-work/phase3/includes/specials/SpecialShortpages.php |
— | — | @@ -28,15 +28,13 @@ |
29 | 29 | } |
30 | 30 | |
31 | 31 | function getQueryInfo() { |
32 | | - global $wgContentNamespaces; |
33 | | - $ns = ( $wgContentNamespaces ? $wgContentNamespaces : NS_MAIN ); |
34 | 32 | return array ( |
35 | 33 | 'tables' => array ( 'page' ), |
36 | 34 | 'fields' => array ( "'{$this->getName()}' AS type", |
37 | 35 | 'page_namespace AS namespace', |
38 | 36 | 'page_title AS title', |
39 | 37 | 'page_len AS value' ), |
40 | | - 'conds' => array ( 'page_namespace' => $ns, |
| 38 | + 'conds' => array ( 'page_namespace' => MWNamespace::getContentNamespaces(), |
41 | 39 | 'page_is_redirect' => 0 ), |
42 | 40 | 'options' => array ( 'USE INDEX' => 'page_len' ) |
43 | 41 | ); |
Index: branches/querypage-work/phase3/includes/specials/SpecialAncientpages.php |
— | — | @@ -28,7 +28,7 @@ |
29 | 29 | 'page_namespace AS namespace', |
30 | 30 | 'page_title AS title', |
31 | 31 | 'rev_timestamp AS value' ), |
32 | | - 'conds' => array( 'page_namespace' => NS_MAIN, |
| 32 | + 'conds' => array( 'page_namespace' => MWNamespace::getContentNamespaces(), |
33 | 33 | 'page_is_redirect' => 0, |
34 | 34 | 'page_latest=rev_id' ) |
35 | 35 | ); |
Index: branches/querypage-work/phase3/includes/specials/SpecialDeadendpages.php |
— | — | @@ -38,13 +38,13 @@ |
39 | 39 | function getQueryInfo() { |
40 | 40 | return array( |
41 | 41 | 'tables' => array( 'page', 'pagelinks' ), |
42 | | - 'fields' => array( "'{$this->getName()} AS type", |
| 42 | + 'fields' => array( "'{$this->getName()}' AS type", |
43 | 43 | 'page_namespace AS namespace', |
44 | 44 | 'page_title AS title', |
45 | 45 | 'page_title AS value' |
46 | 46 | ), |
47 | 47 | 'conds' => array( 'pl_from IS NULL', |
48 | | - 'page_namespace' => NS_MAIN, |
| 48 | + 'page_namespace' => MWNamespace::getContentNamespaces(), |
49 | 49 | 'page_is_redirect' => 0 |
50 | 50 | ), |
51 | 51 | 'join_conds' => array( 'pagelinks' => array( 'LEFT JOIN', array( |