MediaWiki  master
SpecialUnusedImages.php
Go to the documentation of this file.
1 <?php
26 
33 
38  parent::__construct( 'Unusedimages' );
39  $this->setDBLoadBalancer( $loadBalancer );
40  }
41 
42  public function isExpensive() {
43  return true;
44  }
45 
46  protected function sortDescending() {
47  return false;
48  }
49 
50  public function isSyndicated() {
51  return false;
52  }
53 
54  public function getQueryInfo() {
55  $retval = [
56  'tables' => [ 'image', 'imagelinks' ],
57  'fields' => [
58  'namespace' => NS_FILE,
59  'title' => 'img_name',
60  'value' => 'img_timestamp',
61  ],
62  'conds' => [ 'il_to IS NULL' ],
63  'join_conds' => [ 'imagelinks' => [ 'LEFT JOIN', 'il_to = img_name' ] ]
64  ];
65 
66  if ( $this->getConfig()->get( MainConfigNames::CountCategorizedImagesAsUsed ) ) {
67  // Order is significant
68  $retval['tables'] = [ 'image', 'page', 'categorylinks',
69  'imagelinks' ];
70  $retval['conds']['page_namespace'] = NS_FILE;
71  $retval['conds'][] = 'cl_from IS NULL';
72  $retval['conds'][] = 'img_name = page_title';
73  $retval['join_conds']['categorylinks'] = [
74  'LEFT JOIN', 'cl_from = page_id' ];
75  $retval['join_conds']['imagelinks'] = [
76  'LEFT JOIN', 'il_to = page_title' ];
77  }
78 
79  return $retval;
80  }
81 
82  public function usesTimestamps() {
83  return true;
84  }
85 
86  protected function getPageHeader() {
87  if ( $this->getConfig()->get( MainConfigNames::CountCategorizedImagesAsUsed ) ) {
88  return $this->msg(
89  'unusedimagestext-categorizedimgisused'
90  )->parseAsBlock();
91  }
92  return $this->msg( 'unusedimagestext' )->parseAsBlock();
93  }
94 
95  protected function getGroupName() {
96  return 'maintenance';
97  }
98 }
const NS_FILE
Definition: Defines.php:70
Variant of QueryPage which uses a gallery to output results, thus suited for reports generating image...
A class containing constants representing the names of configuration variables.
setDBLoadBalancer(ILoadBalancer $loadBalancer)
Definition: QueryPage.php:895
ILoadBalancer null $loadBalancer
Definition: QueryPage.php:72
msg( $key,... $params)
Wrapper around wfMessage that sets the current context.
getConfig()
Shortcut to get main config object.
A special page that lists unused images.
usesTimestamps()
Does this query return timestamps rather than integers in its 'value' field? If true,...
sortDescending()
Override to sort by increasing values.
getPageHeader()
The content returned by this function will be output before any result.
getGroupName()
Under which header this special page is listed in Special:SpecialPages See messages 'specialpages-gro...
isSyndicated()
Sometimes we don't want to build rss / atom feeds.
__construct(ILoadBalancer $loadBalancer)
isExpensive()
Is this query expensive (for some definition of expensive)? Then we don't let it run in miser mode.
getQueryInfo()
Subclasses return an SQL query here, formatted as an array with the following keys: tables => Table(s...
Database cluster connection, tracking, load balancing, and transaction manager interface.