MediaWiki  1.30.2
SpecialWantedpages.php
Go to the documentation of this file.
1 <?php
30 
31  function __construct( $name = 'Wantedpages' ) {
32  parent::__construct( $name );
33  }
34 
35  function isIncludable() {
36  return true;
37  }
38 
39  function execute( $par ) {
40  $inc = $this->including();
41 
42  if ( $inc ) {
43  $this->limit = (int)$par;
44  $this->offset = 0;
45  }
46  $this->setListoutput( $inc );
47  $this->shownavigation = !$inc;
48  parent::execute( $par );
49  }
50 
51  function getQueryInfo() {
52  $dbr = wfGetDB( DB_REPLICA );
53  $count = $this->getConfig()->get( 'WantedPagesThreshold' ) - 1;
54  $query = [
55  'tables' => [
56  'pagelinks',
57  'pg1' => 'page',
58  'pg2' => 'page'
59  ],
60  'fields' => [
61  'namespace' => 'pl_namespace',
62  'title' => 'pl_title',
63  'value' => 'COUNT(*)'
64  ],
65  'conds' => [
66  'pg1.page_namespace IS NULL',
67  'pl_namespace NOT IN (' . $dbr->makeList( [ NS_USER, NS_USER_TALK ] ) . ')',
68  'pg2.page_namespace != ' . $dbr->addQuotes( NS_MEDIAWIKI ),
69  ],
70  'options' => [
71  'HAVING' => [
72  'COUNT(*) > ' . $dbr->addQuotes( $count ),
73  'COUNT(*) > SUM(pg2.page_is_redirect)'
74  ],
75  'GROUP BY' => [ 'pl_namespace', 'pl_title' ]
76  ],
77  'join_conds' => [
78  'pg1' => [
79  'LEFT JOIN', [
80  'pg1.page_namespace = pl_namespace',
81  'pg1.page_title = pl_title'
82  ]
83  ],
84  'pg2' => [ 'LEFT JOIN', 'pg2.page_id = pl_from' ]
85  ]
86  ];
87  // Replacement for the WantedPages::getSQL hook
88  // Avoid PHP 7.1 warning from passing $this by reference
89  $wantedPages = $this;
90  Hooks::run( 'WantedPages::getQueryInfo', [ &$wantedPages, &$query ] );
91 
92  return $query;
93  }
94 
95  protected function getGroupName() {
96  return 'maintenance';
97  }
98 }
QueryPage\setListoutput
setListoutput( $bool)
A mutator for $this->listoutput;.
Definition: QueryPage.php:118
WantedPagesPage\getQueryInfo
getQueryInfo()
Subclasses return an SQL query here, formatted as an array with the following keys: tables => Table(s...
Definition: SpecialWantedpages.php:51
$name
Allows to change the fields on the form that will be generated $name
Definition: hooks.txt:302
php
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
Definition: injection.txt:35
$query
null for the wiki Added should default to null in handler for backwards compatibility add a value to it if you want to add a cookie that have to vary cache options can modify $query
Definition: hooks.txt:1581
WantedPagesPage\execute
execute( $par)
This is the actual workhorse.
Definition: SpecialWantedpages.php:39
SpecialPage\getConfig
getConfig()
Shortcut to get main config object.
Definition: SpecialPage.php:760
wfGetDB
wfGetDB( $db, $groups=[], $wiki=false)
Get a Database object.
Definition: GlobalFunctions.php:2856
WantedPagesPage\__construct
__construct( $name='Wantedpages')
Definition: SpecialWantedpages.php:31
WantedPagesPage\getGroupName
getGroupName()
Under which header this special page is listed in Special:SpecialPages See messages 'specialpages-gro...
Definition: SpecialWantedpages.php:95
DB_REPLICA
const DB_REPLICA
Definition: defines.php:25
execute
$batch execute()
NS_USER_TALK
const NS_USER_TALK
Definition: Defines.php:68
WantedPagesPage\isIncludable
isIncludable()
Whether it's allowed to transclude the special page via {{Special:Foo/params}}.
Definition: SpecialWantedpages.php:35
$dbr
if(! $regexes) $dbr
Definition: cleanup.php:94
WantedPagesPage
A special page that lists most linked pages that does not exist.
Definition: SpecialWantedpages.php:29
NS_USER
const NS_USER
Definition: Defines.php:67
NS_MEDIAWIKI
const NS_MEDIAWIKI
Definition: Defines.php:73
Hooks\run
static run( $event, array $args=[], $deprecatedVersion=null)
Call hook functions defined in Hooks::register and $wgHooks.
Definition: Hooks.php:203
SpecialPage\including
including( $x=null)
Whether the special page is being evaluated via transclusion.
Definition: SpecialPage.php:226
WantedQueryPage
Class definition for a wanted query page like WantedPages, WantedTemplates, etc.
Definition: WantedQueryPage.php:32