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