MediaWiki REL1_39
SpecialListDuplicatedFiles.php
Go to the documentation of this file.
1<?php
31
38
43 public function __construct(
44 ILoadBalancer $loadBalancer,
45 LinkBatchFactory $linkBatchFactory
46 ) {
47 parent::__construct( 'ListDuplicatedFiles' );
48 $this->setDBLoadBalancer( $loadBalancer );
49 $this->setLinkBatchFactory( $linkBatchFactory );
50 }
51
52 public function isExpensive() {
53 return true;
54 }
55
56 public function isSyndicated() {
57 return false;
58 }
59
71 public function getQueryInfo() {
72 return [
73 'tables' => [ 'image' ],
74 'fields' => [
75 'namespace' => NS_FILE,
76 'title' => 'MIN(img_name)',
77 'value' => 'count(*)'
78 ],
79 'options' => [
80 'GROUP BY' => 'img_sha1',
81 'HAVING' => 'count(*) > 1',
82 ],
83 ];
84 }
85
92 public function preprocessResults( $db, $res ) {
94 }
95
101 public function formatResult( $skin, $result ) {
102 // Future version might include a list of the first 5 duplicates
103 // perhaps separated by an "↔".
104 $image1 = Title::makeTitle( $result->namespace, $result->title );
105 $dupeSearch = SpecialPage::getTitleFor( 'FileDuplicateSearch', $image1->getDBkey() );
106
107 $msg = $this->msg( 'listduplicatedfiles-entry' )
108 ->params( $image1->getText() )
109 ->numParams( $result->value - 1 )
110 ->params( $dupeSearch->getPrefixedDBkey() );
111
112 return $msg->parse();
113 }
114
115 public function execute( $par ) {
116 $this->addHelpLink( 'Help:Managing_files' );
117 parent::execute( $par );
118 }
119
120 protected function getGroupName() {
121 return 'media';
122 }
123}
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:42
executeLBFromResultWrapper(IResultWrapper $res, $ns=null)
Creates a new LinkBatch object, adds all pages from the passed result wrapper (MUST include title and...
setDBLoadBalancer(ILoadBalancer $loadBalancer)
setLinkBatchFactory(LinkBatchFactory $linkBatchFactory)
Special:ListDuplicatedFiles Lists all files where the current version is a duplicate of the current v...
isExpensive()
Should this query page only be updated offline on large wikis?
__construct(ILoadBalancer $loadBalancer, LinkBatchFactory $linkBatchFactory)
execute( $par)
This is the actual workhorse.
preprocessResults( $db, $res)
Pre-fill the link cache.
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.
getQueryInfo()
Get all the duplicates by grouping on sha1s.
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.
Basic database interface for live and lazy-loaded relation database handles.
Definition IDatabase.php:39
Create and track the database connections and transactions for a given database cluster.
Result wrapper for grabbing data queried from an IDatabase object.