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