MediaWiki  master
SpecialLonelyPages.php
Go to the documentation of this file.
1 <?php
27 
35 
37  private $namespaceInfo;
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 }
SpecialPage\msg
msg( $key,... $params)
Wrapper around wfMessage that sets the current context.
Definition: SpecialPage.php:911
SpecialLonelyPages\getOrderFields
getOrderFields()
Subclasses return an array of fields to order by here.
Definition: SpecialLonelyPages.php:111
SpecialLonelyPages\isSyndicated
isSyndicated()
Sometime we don't want to build rss / atom feeds.
Definition: SpecialLonelyPages.php:70
MediaWiki\Languages\LanguageConverterFactory
An interface for creating language converters.
Definition: LanguageConverterFactory.php:46
SpecialLonelyPages\sortDescending
sortDescending()
Override to sort by increasing values.
Definition: SpecialLonelyPages.php:62
SpecialLonelyPages\isExpensive
isExpensive()
Is this query expensive (for some definition of expensive)? Then we don't let it run in miser mode.
Definition: SpecialLonelyPages.php:66
PageQueryPage
Variant of QueryPage which formats the result as a simple link to the page.
Definition: PageQueryPage.php:34
QueryPage\setLinkBatchFactory
setLinkBatchFactory(LinkBatchFactory $linkBatchFactory)
Definition: QueryPage.php:135
SpecialPage\getHookRunner
getHookRunner()
Definition: SpecialPage.php:1094
MediaWiki\Languages\LanguageConverterFactory\getLanguageConverter
getLanguageConverter( $language=null)
Provide a LanguageConverter for given language.
Definition: LanguageConverterFactory.php:125
SpecialLonelyPages\getPageHeader
getPageHeader()
The content returned by this function will be output before any result.
Definition: SpecialLonelyPages.php:58
MediaWiki\Cache\LinkBatchFactory
Definition: LinkBatchFactory.php:39
SpecialLonelyPages
A special page looking for articles with no article linking to them, thus being lonely.
Definition: SpecialLonelyPages.php:34
SpecialLonelyPages\getQueryInfo
getQueryInfo()
Subclasses return an SQL query here, formatted as an array with the following keys: tables => Table(s...
Definition: SpecialLonelyPages.php:74
SpecialLonelyPages\getGroupName
getGroupName()
Under which header this special page is listed in Special:SpecialPages See messages 'specialpages-gro...
Definition: SpecialLonelyPages.php:121
PageQueryPage\setLanguageConverter
setLanguageConverter(ILanguageConverter $languageConverter)
Definition: PageQueryPage.php:57
QueryPage\setDBLoadBalancer
setDBLoadBalancer(ILoadBalancer $loadBalancer)
Definition: QueryPage.php:891
QueryPage\$linkBatchFactory
LinkBatchFactory null $linkBatchFactory
Definition: QueryPage.php:74
SpecialLonelyPages\$namespaceInfo
NamespaceInfo $namespaceInfo
Definition: SpecialLonelyPages.php:37
SpecialLonelyPages\__construct
__construct(NamespaceInfo $namespaceInfo, ILoadBalancer $loadBalancer, LinkBatchFactory $linkBatchFactory, LanguageConverterFactory $languageConverterFactory)
Definition: SpecialLonelyPages.php:45
QueryPage\$loadBalancer
ILoadBalancer null $loadBalancer
Definition: QueryPage.php:71
NamespaceInfo
This is a utility class for dealing with namespaces that encodes all the "magic" behaviors of them ba...
Definition: NamespaceInfo.php:35
Wikimedia\Rdbms\ILoadBalancer
Database cluster connection, tracking, load balancing, and transaction manager interface.
Definition: ILoadBalancer.php:81