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