MediaWiki REL1_41
SpecialLonelyPages.php
Go to the documentation of this file.
1<?php
24namespace MediaWiki\Specials;
25
32
40
41 private NamespaceInfo $namespaceInfo;
42 private LinksMigration $linksMigration;
43
51 public function __construct(
52 NamespaceInfo $namespaceInfo,
53 IConnectionProvider $dbProvider,
54 LinkBatchFactory $linkBatchFactory,
55 LanguageConverterFactory $languageConverterFactory,
56 LinksMigration $linksMigration
57 ) {
58 parent::__construct( 'Lonelypages' );
59 $this->namespaceInfo = $namespaceInfo;
60 $this->setDatabaseProvider( $dbProvider );
61 $this->setLinkBatchFactory( $linkBatchFactory );
62 $this->setLanguageConverter( $languageConverterFactory->getLanguageConverter( $this->getContentLanguage() ) );
63 $this->linksMigration = $linksMigration;
64 }
65
66 protected function getPageHeader() {
67 return $this->msg( 'lonelypagestext' )->parseAsBlock();
68 }
69
70 protected function sortDescending() {
71 return false;
72 }
73
74 public function isExpensive() {
75 return true;
76 }
77
78 public function isSyndicated() {
79 return false;
80 }
81
82 public function getQueryInfo() {
83 $queryInfo = $this->linksMigration->getQueryInfo(
84 'templatelinks',
85 'templatelinks',
86 'LEFT JOIN'
87 );
88 [ $ns, $title ] = $this->linksMigration->getTitleFields( 'templatelinks' );
89 $tables = array_merge( [ 'page', 'pagelinks' ], $queryInfo['tables'] );
90 $conds = [
91 'pl_namespace' => null,
92 'page_namespace' => $this->namespaceInfo->getContentNamespaces(),
93 'page_is_redirect' => 0,
94 'tl_from' => null,
95 ];
96 $joinConds = [
97 'pagelinks' => [
98 'LEFT JOIN', [
99 'pl_namespace = page_namespace',
100 'pl_title = page_title'
101 ]
102 ],
103 ];
104 $templatelinksJoin = [
105 'LEFT JOIN', [
106 "$ns = page_namespace",
107 "$title = page_title"
108 ]
109 ];
110 if ( in_array( 'linktarget', $tables ) ) {
111 $joinConds['linktarget'] = $templatelinksJoin;
112 } else {
113 $joinConds['templatelinks'] = $templatelinksJoin;
114 }
115
116 // Allow extensions to modify the query
117 $this->getHookRunner()->onLonelyPagesQuery( $tables, $conds, $joinConds );
118
119 return [
120 'tables' => $tables,
121 'fields' => [
122 'namespace' => 'page_namespace',
123 'title' => 'page_title',
124 ],
125 'conds' => $conds,
126 'join_conds' => array_merge( $joinConds, $queryInfo['joins'] )
127 ];
128 }
129
130 protected function getOrderFields() {
131 // For some crazy reason ordering by a constant
132 // causes a filesort in MySQL 5
133 if ( count( $this->namespaceInfo->getContentNamespaces() ) > 1 ) {
134 return [ 'page_namespace', 'page_title' ];
135 } else {
136 return [ 'page_title' ];
137 }
138 }
139
140 protected function getGroupName() {
141 return 'maintenance';
142 }
143}
144
148class_alias( SpecialLonelyPages::class, 'SpecialLonelyPages' );
An interface for creating language converters.
getLanguageConverter( $language=null)
Provide a LanguageConverter for given language.
Service for compat reading of links tables.
Variant of QueryPage which formats the result as a simple link to the page.
setLanguageConverter(ILanguageConverter $languageConverter)
setDatabaseProvider(IConnectionProvider $databaseProvider)
setLinkBatchFactory(LinkBatchFactory $linkBatchFactory)
msg( $key,... $params)
Wrapper around wfMessage that sets the current context.
A special page looking for articles with no article linking to them, thus being lonely.
isExpensive()
Should this query page only be updated offline on large wikis?
getQueryInfo()
Subclasses return an SQL query here, formatted as an array with the following keys: tables => Table(s...
getPageHeader()
The content returned by this function will be output before any result.
getGroupName()
Under which header this special page is listed in Special:SpecialPages See messages 'specialpages-gro...
sortDescending()
Override to sort by increasing values.
isSyndicated()
Sometimes we don't want to build rss / atom feeds.
getOrderFields()
Subclasses return an array of fields to order by here.
__construct(NamespaceInfo $namespaceInfo, IConnectionProvider $dbProvider, LinkBatchFactory $linkBatchFactory, LanguageConverterFactory $languageConverterFactory, LinksMigration $linksMigration)
This is a utility class for dealing with namespaces that encodes all the "magic" behaviors of them ba...
Provide primary and replica IDatabase connections.
This program is free software; you can redistribute it and/or modify it under the terms of the GNU Ge...