MediaWiki master
SpecialListDuplicatedFiles.php
Go to the documentation of this file.
1<?php
23namespace MediaWiki\Specials;
24
29use Skin;
30use stdClass;
34
43
48 public function __construct(
49 IConnectionProvider $dbProvider,
50 LinkBatchFactory $linkBatchFactory
51 ) {
52 parent::__construct( 'ListDuplicatedFiles' );
53 $this->setDatabaseProvider( $dbProvider );
54 $this->setLinkBatchFactory( $linkBatchFactory );
55 }
56
57 public function isExpensive() {
58 return true;
59 }
60
61 public function isSyndicated() {
62 return false;
63 }
64
76 public function getQueryInfo() {
77 return [
78 'tables' => [ 'image' ],
79 'fields' => [
80 'namespace' => NS_FILE,
81 'title' => 'MIN(img_name)',
82 'value' => 'count(*)'
83 ],
84 'options' => [
85 'GROUP BY' => 'img_sha1',
86 'HAVING' => 'count(*) > 1',
87 ],
88 ];
89 }
90
97 public function preprocessResults( $db, $res ) {
98 $this->executeLBFromResultWrapper( $res );
99 }
100
106 public function formatResult( $skin, $result ) {
107 // Future version might include a list of the first 5 duplicates
108 // perhaps separated by an "↔".
109 $image1 = Title::makeTitle( $result->namespace, $result->title );
110 $dupeSearch = SpecialPage::getTitleFor( 'FileDuplicateSearch', $image1->getDBkey() );
111
112 $msg = $this->msg( 'listduplicatedfiles-entry' )
113 ->params( $image1->getText() )
114 ->numParams( $result->value - 1 )
115 ->params( $dupeSearch->getPrefixedDBkey() );
116
117 return $msg->parse();
118 }
119
120 public function execute( $par ) {
121 $this->addHelpLink( 'Help:Managing_files' );
122 parent::execute( $par );
123 }
124
125 protected function getGroupName() {
126 return 'media';
127 }
128}
129
131class_alias( SpecialListDuplicatedFiles::class, 'SpecialListDuplicatedFiles' );
const NS_FILE
Definition Defines.php:71
This is a class for doing query pages; since they're almost all the same, we factor out some of the f...
Definition QueryPage.php:89
setDatabaseProvider(IConnectionProvider $databaseProvider)
executeLBFromResultWrapper(IResultWrapper $res, $ns=null)
Creates a new LinkBatch object, adds all pages from the passed result wrapper (MUST include title and...
setLinkBatchFactory(LinkBatchFactory $linkBatchFactory)
Parent class for all special pages.
static getTitleFor( $name, $subpage=false, $fragment='')
Get a localised Title object for a specified special page name If you don't need a full Title object,...
msg( $key,... $params)
Wrapper around wfMessage that sets the current context.
addHelpLink( $to, $overrideBaseUrl=false)
Adds help link with an icon via page indicators.
List all files where the current version is a duplicate of the current version of another file.
getQueryInfo()
Get all the duplicates by grouping on sha1s.
isSyndicated()
Sometimes we don't want to build rss / atom feeds.
isExpensive()
Should this query page only be updated offline on large wikis?
__construct(IConnectionProvider $dbProvider, LinkBatchFactory $linkBatchFactory)
getGroupName()
Under which header this special page is listed in Special:SpecialPages See messages 'specialpages-gro...
preprocessResults( $db, $res)
Pre-fill the link cache.
Represents a title within MediaWiki.
Definition Title.php:79
The base class for all skins.
Definition Skin.php:59
Provide primary and replica IDatabase connections.
Basic database interface for live and lazy-loaded relation database handles.
Definition IDatabase.php:39
Result wrapper for grabbing data queried from an IDatabase object.