MediaWiki master
SpecialMostImages.php
Go to the documentation of this file.
1<?php
9namespace MediaWiki\Specials;
10
15
23
24 private int $imageLinksMigrationStage;
25
26 public function __construct( IConnectionProvider $dbProvider ) {
27 parent::__construct( 'Mostimages' );
28 $this->setDatabaseProvider( $dbProvider );
29 $this->imageLinksMigrationStage = $this->getConfig()->get( MainConfigNames::ImageLinksSchemaMigrationStage );
30 }
31
33 public function isExpensive() {
34 return true;
35 }
36
38 public function isSyndicated() {
39 return false;
40 }
41
43 public function getQueryInfo() {
44 if ( $this->imageLinksMigrationStage & SCHEMA_COMPAT_READ_OLD ) {
45 $linksTables = [ 'imagelinks' ];
46 $titleField = 'il_to';
47 $joinConds = [];
48 } else {
49 $linksTables = [ 'imagelinks', 'linktarget' ];
50 $titleField = 'lt_title';
51 $joinConds = [ 'linktarget' => [ 'JOIN', 'il_target_id = lt_id' ] ];
52 }
53
54 return [
55 'tables' => $linksTables,
56 'fields' => [
57 'namespace' => NS_FILE,
58 'title' => $titleField,
59 'value' => 'COUNT(*)'
60 ],
61 'join_conds' => $joinConds,
62 'options' => [
63 'GROUP BY' => $titleField,
64 'HAVING' => 'COUNT(*) > 1'
65 ]
66 ];
67 }
68
70 protected function getCellHtml( $row ) {
71 return $this->msg( 'nimagelinks' )->numParams( $row->value )->escaped() . '<br />';
72 }
73
75 protected function getGroupName() {
76 return 'highuse';
77 }
78
80 protected function getRecacheDB() {
81 return $this->getDatabaseProvider()->getReplicaDatabase(
82 ImageLinksTable::VIRTUAL_DOMAIN,
83 'vslow'
84 );
85 }
86}
87
92class_alias( SpecialMostImages::class, 'MostimagesPage' );
const NS_FILE
Definition Defines.php:57
const SCHEMA_COMPAT_READ_OLD
Definition Defines.php:294
A class containing constants representing the names of configuration variables.
const ImageLinksSchemaMigrationStage
Name constant for the ImageLinksSchemaMigrationStage setting, for use with Config::get()
Variant of QueryPage which uses a gallery to output results, thus suited for reports generating image...
setDatabaseProvider(IConnectionProvider $databaseProvider)
getConfig()
Shortcut to get main config object.
msg( $key,... $params)
Wrapper around wfMessage that sets the current context.
List of the most used images.
getGroupName()
Under which header this special page is listed in Special:SpecialPages See messages 'specialpages-gro...
getCellHtml( $row)
Get additional HTML to be shown in a results' cell.to overridestring
getRecacheDB()
Get a DB connection to be used for slow recache queries.to override IReadableDatabase
isExpensive()
Should this query page only be updated offline on large wikis?If the query for this page is considere...
__construct(IConnectionProvider $dbProvider)
isSyndicated()
Sometimes we don't want to build rss / atom feeds.to override bool
getQueryInfo()
Subclasses return an SQL query here, formatted as an array with the following keys: tables => Table(s...
Provide primary and replica IDatabase connections.