MediaWiki  master
SpecialLonelyPages.php
Go to the documentation of this file.
1 <?php
25 
33  function __construct( $name = 'Lonelypages' ) {
34  parent::__construct( $name );
35  }
36 
37  function getPageHeader() {
38  return $this->msg( 'lonelypagestext' )->parseAsBlock();
39  }
40 
41  function sortDescending() {
42  return false;
43  }
44 
45  function isExpensive() {
46  return true;
47  }
48 
49  function isSyndicated() {
50  return false;
51  }
52 
53  function getQueryInfo() {
54  $tables = [ 'page', 'pagelinks', 'templatelinks' ];
55  $conds = [
56  'pl_namespace IS NULL',
57  'page_namespace' => MediaWikiServices::getInstance()->getNamespaceInfo()->
58  getContentNamespaces(),
59  'page_is_redirect' => 0,
60  'tl_namespace IS NULL'
61  ];
62  $joinConds = [
63  'pagelinks' => [
64  'LEFT JOIN', [
65  'pl_namespace = page_namespace',
66  'pl_title = page_title'
67  ]
68  ],
69  'templatelinks' => [
70  'LEFT JOIN', [
71  'tl_namespace = page_namespace',
72  'tl_title = page_title'
73  ]
74  ]
75  ];
76 
77  // Allow extensions to modify the query
78  Hooks::run( 'LonelyPagesQuery', [ &$tables, &$conds, &$joinConds ] );
79 
80  return [
81  'tables' => $tables,
82  'fields' => [
83  'namespace' => 'page_namespace',
84  'title' => 'page_title',
85  'value' => 'page_title'
86  ],
87  'conds' => $conds,
88  'join_conds' => $joinConds
89  ];
90  }
91 
92  function getOrderFields() {
93  // For some crazy reason ordering by a constant
94  // causes a filesort in MySQL 5
95  if ( count( MediaWikiServices::getInstance()->getNamespaceInfo()->
96  getContentNamespaces() ) > 1
97  ) {
98  return [ 'page_namespace', 'page_title' ];
99  } else {
100  return [ 'page_title' ];
101  }
102  }
103 
104  protected function getGroupName() {
105  return 'maintenance';
106  }
107 }
A special page looking for articles with no article linking to them, thus being lonely.
msg( $key,... $params)
Wrapper around wfMessage that sets the current context.
__construct( $name='Lonelypages')
Variant of QueryPage which formats the result as a simple link to the page.
static run( $event, array $args=[], $deprecatedVersion=null)
Call hook functions defined in Hooks::register and $wgHooks.
Definition: Hooks.php:200