MediaWiki REL1_37
SpecialWantedpages.php
Go to the documentation of this file.
1<?php
26
33
38 public function __construct(
39 ILoadBalancer $loadBalancer,
40 LinkBatchFactory $linkBatchFactory
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}
const NS_USER
Definition Defines.php:66
const NS_MEDIAWIKI
Definition Defines.php:72
const NS_USER_TALK
Definition Defines.php:67
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.
Database cluster connection, tracking, load balancing, and transaction manager interface.