MediaWiki master
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( 'pagelinks', 'pagelinks', 'LEFT JOIN' );
84 $tables = [ 'page', 'linktarget', 'templatelinks', 'pagelinks' ];
85 $conds = [
86 'pl_from' => null,
87 'page_namespace' => $this->namespaceInfo->getContentNamespaces(),
88 'page_is_redirect' => 0,
89 'tl_from' => null,
90 ];
91 $joinConds = [
92 'templatelinks' => [ 'LEFT JOIN', [ 'tl_target_id=lt_id' ] ],
93 'linktarget' => [
94 'LEFT JOIN', [
95 "lt_namespace = page_namespace",
96 "lt_title = page_title"
97 ]
98 ]
99 ];
100
101 if ( !in_array( 'linktarget', $queryInfo['tables'] ) ) {
102 $joinConds['pagelinks'] = [
103 'LEFT JOIN', [
104 "pl_namespace = page_namespace",
105 "pl_title = page_title"
106 ]
107 ];
108 }
109
110 // Allow extensions to modify the query
111 $this->getHookRunner()->onLonelyPagesQuery( $tables, $conds, $joinConds );
112
113 return [
114 'tables' => $tables,
115 'fields' => [
116 'namespace' => 'page_namespace',
117 'title' => 'page_title',
118 ],
119 'conds' => $conds,
120 'join_conds' => array_merge( $joinConds, $queryInfo['joins'] )
121 ];
122 }
123
124 protected function getOrderFields() {
125 // For some crazy reason ordering by a constant
126 // causes a filesort in MySQL 5
127 if ( count( $this->namespaceInfo->getContentNamespaces() ) > 1 ) {
128 return [ 'page_namespace', 'page_title' ];
129 } else {
130 return [ 'page_title' ];
131 }
132 }
133
134 protected function getGroupName() {
135 return 'maintenance';
136 }
137}
138
140class_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...