MediaWiki  master
SpecialListDuplicatedFiles.php
Go to the documentation of this file.
1 <?php
31 
38 
43  public function __construct(
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 }
SpecialPage\msg
msg( $key,... $params)
Wrapper around wfMessage that sets the current context.
Definition: SpecialPage.php:911
SpecialListDuplicatedFiles\__construct
__construct(ILoadBalancer $loadBalancer, LinkBatchFactory $linkBatchFactory)
Definition: SpecialListDuplicatedFiles.php:43
SpecialListDuplicatedFiles\getQueryInfo
getQueryInfo()
Get all the duplicates by grouping on sha1s.
Definition: SpecialListDuplicatedFiles.php:71
SpecialPage\getTitleFor
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,...
Definition: SpecialPage.php:107
$res
$res
Definition: testCompression.php:57
SpecialListDuplicatedFiles\execute
execute( $par)
This is the actual workhorse.
Definition: SpecialListDuplicatedFiles.php:115
QueryPage
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:41
QueryPage\executeLBFromResultWrapper
executeLBFromResultWrapper(IResultWrapper $res, $ns=null)
Creates a new LinkBatch object, adds all pages from the passed result wrapper (MUST include title and...
Definition: QueryPage.php:873
SpecialListDuplicatedFiles\preprocessResults
preprocessResults( $db, $res)
Pre-fill the link cache.
Definition: SpecialListDuplicatedFiles.php:92
Wikimedia\Rdbms\IDatabase
Basic database interface for live and lazy-loaded relation database handles.
Definition: IDatabase.php:38
QueryPage\setLinkBatchFactory
setLinkBatchFactory(LinkBatchFactory $linkBatchFactory)
Definition: QueryPage.php:135
SpecialPage\addHelpLink
addHelpLink( $to, $overrideBaseUrl=false)
Adds help link with an icon via page indicators.
Definition: SpecialPage.php:947
SpecialListDuplicatedFiles\formatResult
formatResult( $skin, $result)
Definition: SpecialListDuplicatedFiles.php:101
SpecialListDuplicatedFiles\isSyndicated
isSyndicated()
Sometime we don't want to build rss / atom feeds.
Definition: SpecialListDuplicatedFiles.php:56
SpecialListDuplicatedFiles
Special:ListDuplicatedFiles Lists all files where the current version is a duplicate of the current v...
Definition: SpecialListDuplicatedFiles.php:37
Wikimedia\Rdbms\IResultWrapper
Result wrapper for grabbing data queried from an IDatabase object.
Definition: IResultWrapper.php:25
MediaWiki\Cache\LinkBatchFactory
Definition: LinkBatchFactory.php:39
Title\makeTitle
static makeTitle( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
Definition: Title.php:680
SpecialListDuplicatedFiles\isExpensive
isExpensive()
Is this query expensive (for some definition of expensive)? Then we don't let it run in miser mode.
Definition: SpecialListDuplicatedFiles.php:52
QueryPage\setDBLoadBalancer
setDBLoadBalancer(ILoadBalancer $loadBalancer)
Definition: QueryPage.php:891
QueryPage\$linkBatchFactory
LinkBatchFactory null $linkBatchFactory
Definition: QueryPage.php:74
QueryPage\$loadBalancer
ILoadBalancer null $loadBalancer
Definition: QueryPage.php:71
NS_FILE
const NS_FILE
Definition: Defines.php:70
SpecialListDuplicatedFiles\getGroupName
getGroupName()
Under which header this special page is listed in Special:SpecialPages See messages 'specialpages-gro...
Definition: SpecialListDuplicatedFiles.php:120
Wikimedia\Rdbms\ILoadBalancer
Database cluster connection, tracking, load balancing, and transaction manager interface.
Definition: ILoadBalancer.php:81