array( 'image' ), 'fields' => array( 'namespace' => NS_FILE, 'title' => 'MIN(img_name)', 'value' => 'count(*)' ), 'options' => array( 'GROUP BY' => 'img_sha1', 'HAVING' => 'count(*) > 1', ), ); } /** * Pre-fill the link cache * * @param IDatabase $db * @param ResultWrapper $res */ function preprocessResults( $db, $res ) { if ( $res->numRows() > 0 ) { $linkBatch = new LinkBatch(); foreach ( $res as $row ) { $linkBatch->add( $row->namespace, $row->title ); } $res->seek( 0 ); $linkBatch->execute(); } } /** * @param Skin $skin * @param object $result Result row * @return string */ function formatResult( $skin, $result ) { // Future version might include a list of the first 5 duplicates // perhaps separated by an "↔". $image1 = Title::makeTitle( $result->namespace, $result->title ); $dupeSearch = SpecialPage::getTitleFor( 'FileDuplicateSearch', $image1->getDBKey() ); $msg = $this->msg( 'listduplicatedfiles-entry' ) ->params( $image1->getText() ) ->numParams( $result->value - 1 ) ->params( $dupeSearch->getPrefixedDBKey() ); return $msg->parse(); } protected function getGroupName() { return 'media'; } }