MediaWiki master
SpecialListDuplicatedFiles.php
Go to the documentation of this file.
1<?php
27namespace MediaWiki\Specials;
28
33use Skin;
34use stdClass;
38
45
50 public function __construct(
51 IConnectionProvider $dbProvider,
52 LinkBatchFactory $linkBatchFactory
53 ) {
54 parent::__construct( 'ListDuplicatedFiles' );
55 $this->setDatabaseProvider( $dbProvider );
56 $this->setLinkBatchFactory( $linkBatchFactory );
57 }
58
59 public function isExpensive() {
60 return true;
61 }
62
63 public function isSyndicated() {
64 return false;
65 }
66
78 public function getQueryInfo() {
79 return [
80 'tables' => [ 'image' ],
81 'fields' => [
82 'namespace' => NS_FILE,
83 'title' => 'MIN(img_name)',
84 'value' => 'count(*)'
85 ],
86 'options' => [
87 'GROUP BY' => 'img_sha1',
88 'HAVING' => 'count(*) > 1',
89 ],
90 ];
91 }
92
99 public function preprocessResults( $db, $res ) {
100 $this->executeLBFromResultWrapper( $res );
101 }
102
108 public function formatResult( $skin, $result ) {
109 // Future version might include a list of the first 5 duplicates
110 // perhaps separated by an "↔".
111 $image1 = Title::makeTitle( $result->namespace, $result->title );
112 $dupeSearch = SpecialPage::getTitleFor( 'FileDuplicateSearch', $image1->getDBkey() );
113
114 $msg = $this->msg( 'listduplicatedfiles-entry' )
115 ->params( $image1->getText() )
116 ->numParams( $result->value - 1 )
117 ->params( $dupeSearch->getPrefixedDBkey() );
118
119 return $msg->parse();
120 }
121
122 public function execute( $par ) {
123 $this->addHelpLink( 'Help:Managing_files' );
124 parent::execute( $par );
125 }
126
127 protected function getGroupName() {
128 return 'media';
129 }
130}
131
133class_alias( SpecialListDuplicatedFiles::class, 'SpecialListDuplicatedFiles' );
const NS_FILE
Definition Defines.php:70
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:88
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.
Special:ListDuplicatedFiles Lists all files where the current version is a duplicate of the current v...
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:78
The base class for all skins.
Definition Skin.php:58
Provide primary and replica IDatabase connections.
Basic database interface for live and lazy-loaded relation database handles.
Definition IDatabase.php:36
Result wrapper for grabbing data queried from an IDatabase object.
This program is free software; you can redistribute it and/or modify it under the terms of the GNU Ge...