MediaWiki REL1_39
SpecialWantedpages.php
Go to the documentation of this file.
1<?php
27
34
39 public function __construct(
40 ILoadBalancer $loadBalancer,
41 LinkBatchFactory $linkBatchFactory
42 ) {
43 parent::__construct( 'Wantedpages' );
44 $this->setDBLoadBalancer( $loadBalancer );
45 $this->setLinkBatchFactory( $linkBatchFactory );
46 }
47
48 public function isIncludable() {
49 return true;
50 }
51
52 public function execute( $par ) {
53 $inc = $this->including();
54
55 if ( $inc ) {
56 $this->limit = (int)$par;
57 $this->offset = 0;
58 }
59 $this->setListoutput( $inc );
60 $this->shownavigation = !$inc;
61 parent::execute( $par );
62 }
63
64 public function getQueryInfo() {
65 $dbr = $this->getDBLoadBalancer()->getConnectionRef( ILoadBalancer::DB_REPLICA );
66 $count = $this->getConfig()->get( MainConfigNames::WantedPagesThreshold ) - 1;
67 $query = [
68 'tables' => [
69 'pagelinks',
70 'pg1' => 'page',
71 'pg2' => 'page'
72 ],
73 'fields' => [
74 'namespace' => 'pl_namespace',
75 'title' => 'pl_title',
76 'value' => 'COUNT(*)'
77 ],
78 'conds' => [
79 'pg1.page_namespace IS NULL',
80 'pl_namespace NOT IN (' . $dbr->makeList( [ NS_USER, NS_USER_TALK ] ) . ')',
81 'pg2.page_namespace != ' . $dbr->addQuotes( NS_MEDIAWIKI ),
82 ],
83 'options' => [
84 'HAVING' => [
85 'COUNT(*) > ' . $dbr->addQuotes( $count ),
86 'COUNT(*) > SUM(pg2.page_is_redirect)'
87 ],
88 'GROUP BY' => [ 'pl_namespace', 'pl_title' ]
89 ],
90 'join_conds' => [
91 'pg1' => [
92 'LEFT JOIN', [
93 'pg1.page_namespace = pl_namespace',
94 'pg1.page_title = pl_title'
95 ]
96 ],
97 'pg2' => [ 'LEFT JOIN', 'pg2.page_id = pl_from' ]
98 ]
99 ];
100 // Replacement for the WantedPages::getSQL hook
101 $this->getHookRunner()->onWantedPages__getQueryInfo( $this, $query );
102
103 return $query;
104 }
105
106 protected function getGroupName() {
107 return 'maintenance';
108 }
109}
const NS_USER
Definition Defines.php:66
const NS_MEDIAWIKI
Definition Defines.php:72
const NS_USER_TALK
Definition Defines.php:67
A class containing constants representing the names of configuration variables.
setListoutput( $bool)
A mutator for $this->listoutput;.
setDBLoadBalancer(ILoadBalancer $loadBalancer)
setLinkBatchFactory(LinkBatchFactory $linkBatchFactory)
getDBLoadBalancer()
getConfig()
Shortcut to get main config object.
including( $x=null)
Whether the special page is being evaluated via transclusion.
A special page that lists most linked pages that does not exist.
__construct(ILoadBalancer $loadBalancer, LinkBatchFactory $linkBatchFactory)
isIncludable()
Whether it's allowed to transclude the special page via {{Special:Foo/params}}.
getGroupName()
Under which header this special page is listed in Special:SpecialPages See messages 'specialpages-gro...
execute( $par)
This is the actual workhorse.
getQueryInfo()
Subclasses return an SQL query here, formatted as an array with the following keys: tables => Table(s...
Class definition for a wanted query page like WantedPages, WantedTemplates, etc.
Create and track the database connections and transactions for a given database cluster.