MediaWiki master
SpecialLonelyPages.php
Go to the documentation of this file.
1<?php
7namespace MediaWiki\Specials;
8
9use MediaWiki\Cache\LinkBatchFactory;
10use MediaWiki\Languages\LanguageConverterFactory;
15
23
24 private NamespaceInfo $namespaceInfo;
25 private LinksMigration $linksMigration;
26
27 public function __construct(
28 NamespaceInfo $namespaceInfo,
29 IConnectionProvider $dbProvider,
30 LinkBatchFactory $linkBatchFactory,
31 LanguageConverterFactory $languageConverterFactory,
32 LinksMigration $linksMigration
33 ) {
34 parent::__construct( 'Lonelypages' );
35 $this->namespaceInfo = $namespaceInfo;
36 $this->setDatabaseProvider( $dbProvider );
37 $this->setLinkBatchFactory( $linkBatchFactory );
38 $this->setLanguageConverter( $languageConverterFactory->getLanguageConverter( $this->getContentLanguage() ) );
39 $this->linksMigration = $linksMigration;
40 }
41
43 protected function getPageHeader() {
44 return $this->msg( 'lonelypagestext' )->parseAsBlock();
45 }
46
48 protected function sortDescending() {
49 return false;
50 }
51
53 public function isExpensive() {
54 return true;
55 }
56
58 public function isSyndicated() {
59 return false;
60 }
61
63 public function getQueryInfo() {
64 $queryInfo = $this->linksMigration->getQueryInfo( 'pagelinks', 'pagelinks', 'LEFT JOIN' );
65 $tables = [ 'page', 'linktarget', 'templatelinks', 'pagelinks' ];
66 $conds = [
67 'pl_from' => null,
68 'page_namespace' => $this->namespaceInfo->getContentNamespaces(),
69 'page_is_redirect' => 0,
70 'tl_from' => null,
71 ];
72 $joinConds = [
73 'templatelinks' => [ 'LEFT JOIN', [ 'tl_target_id=lt_id' ] ],
74 'linktarget' => [
75 'LEFT JOIN', [
76 "lt_namespace = page_namespace",
77 "lt_title = page_title"
78 ]
79 ]
80 ];
81
82 if ( !in_array( 'linktarget', $queryInfo['tables'] ) ) {
83 $joinConds['pagelinks'] = [
84 'LEFT JOIN', [
85 "pl_namespace = page_namespace",
86 "pl_title = page_title"
87 ]
88 ];
89 }
90
91 // Allow extensions to modify the query
92 $this->getHookRunner()->onLonelyPagesQuery( $tables, $conds, $joinConds );
93
94 return [
95 'tables' => $tables,
96 'fields' => [
97 'namespace' => 'page_namespace',
98 'title' => 'page_title',
99 ],
100 'conds' => $conds,
101 'join_conds' => array_merge( $joinConds, $queryInfo['joins'] )
102 ];
103 }
104
106 protected function getOrderFields() {
107 // For some crazy reason ordering by a constant
108 // causes a filesort in MySQL 5
109 if ( count( $this->namespaceInfo->getContentNamespaces() ) > 1 ) {
110 return [ 'page_namespace', 'page_title' ];
111 } else {
112 return [ 'page_title' ];
113 }
114 }
115
117 protected function getGroupName() {
118 return 'maintenance';
119 }
120}
121
123class_alias( SpecialLonelyPages::class, 'SpecialLonelyPages' );
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.
List of articles with no article linking to them, thus being lonely.
isExpensive()
Should this query page only be updated offline on large wikis?If the query for this page is considere...
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.to override string
getGroupName()
Under which header this special page is listed in Special:SpecialPages See messages 'specialpages-gro...
sortDescending()
Override to sort by increasing values.to override bool
isSyndicated()
Sometimes we don't want to build rss / atom feeds.to override bool
getOrderFields()
Subclasses return an array of fields to order by here.Don't append DESC to the field names,...
__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.