MediaWiki REL1_37
SpecialLonelyPages.php
Go to the documentation of this file.
1<?php
27
35
38
45 public function __construct(
49 LanguageConverterFactory $languageConverterFactory
50 ) {
51 parent::__construct( 'Lonelypages' );
52 $this->namespaceInfo = $namespaceInfo;
53 $this->setDBLoadBalancer( $loadBalancer );
54 $this->setLinkBatchFactory( $linkBatchFactory );
55 $this->setLanguageConverter( $languageConverterFactory->getLanguageConverter( $this->getContentLanguage() ) );
56 }
57
58 protected function getPageHeader() {
59 return $this->msg( 'lonelypagestext' )->parseAsBlock();
60 }
61
62 protected function sortDescending() {
63 return false;
64 }
65
66 public function isExpensive() {
67 return true;
68 }
69
70 public function isSyndicated() {
71 return false;
72 }
73
74 public function getQueryInfo() {
75 $tables = [ 'page', 'pagelinks', 'templatelinks' ];
76 $conds = [
77 'pl_namespace IS NULL',
78 'page_namespace' => $this->namespaceInfo->getContentNamespaces(),
79 'page_is_redirect' => 0,
80 'tl_namespace IS NULL'
81 ];
82 $joinConds = [
83 'pagelinks' => [
84 'LEFT JOIN', [
85 'pl_namespace = page_namespace',
86 'pl_title = page_title'
87 ]
88 ],
89 'templatelinks' => [
90 'LEFT JOIN', [
91 'tl_namespace = page_namespace',
92 'tl_title = page_title'
93 ]
94 ]
95 ];
96
97 // Allow extensions to modify the query
98 $this->getHookRunner()->onLonelyPagesQuery( $tables, $conds, $joinConds );
99
100 return [
101 'tables' => $tables,
102 'fields' => [
103 'namespace' => 'page_namespace',
104 'title' => 'page_title',
105 ],
106 'conds' => $conds,
107 'join_conds' => $joinConds
108 ];
109 }
110
111 protected function getOrderFields() {
112 // For some crazy reason ordering by a constant
113 // causes a filesort in MySQL 5
114 if ( count( $this->namespaceInfo->getContentNamespaces() ) > 1 ) {
115 return [ 'page_namespace', 'page_title' ];
116 } else {
117 return [ 'page_title' ];
118 }
119 }
120
121 protected function getGroupName() {
122 return 'maintenance';
123 }
124}
An interface for creating language converters.
getLanguageConverter( $language=null)
Provide a LanguageConverter for given language.
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)
LinkBatchFactory null $linkBatchFactory
Definition QueryPage.php:74
setLinkBatchFactory(LinkBatchFactory $linkBatchFactory)
ILoadBalancer null $loadBalancer
Definition QueryPage.php:71
A special page looking for articles with no article linking to them, thus being lonely.
isExpensive()
Is this query expensive (for some definition of expensive)? Then we don't let it run in miser mode.
getGroupName()
Under which header this special page is listed in Special:SpecialPages See messages 'specialpages-gro...
getQueryInfo()
Subclasses return an SQL query here, formatted as an array with the following keys: tables => Table(s...
NamespaceInfo $namespaceInfo
getOrderFields()
Subclasses return an array of fields to order by here.
isSyndicated()
Sometime we don't want to build rss / atom feeds.
__construct(NamespaceInfo $namespaceInfo, ILoadBalancer $loadBalancer, LinkBatchFactory $linkBatchFactory, LanguageConverterFactory $languageConverterFactory)
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.
Database cluster connection, tracking, load balancing, and transaction manager interface.