43 parent::__construct( $query, $moduleName,
'df' );
56 $this->
run( $resultPageSet );
62 private function run( $resultPageSet =
null ) {
64 $namespaces = $this->
getPageSet()->getGoodAndMissingTitlesByNamespace();
65 if ( empty( $namespaces[
NS_FILE] ) ) {
70 if ( $params[
'dir'] ==
'descending' ) {
71 $images = array_reverse( $images );
74 $skipUntilThisDup =
false;
75 if ( isset( $params[
'continue'] ) ) {
76 $cont = explode(
'|', $params[
'continue'] );
78 $fromImage = $cont[0];
79 $skipUntilThisDup = $cont[1];
81 foreach ( $images as $image => $pageId ) {
82 if ( $image < $fromImage ) {
83 unset( $images[$image] );
90 $filesToFind = array_keys( $images );
91 if ( $params[
'localonly'] ) {
92 $files = $this->repoGroup->getLocalRepo()->findFiles( $filesToFind );
94 $files = $this->repoGroup->findFiles( $filesToFind );
102 foreach ( $files as
$file ) {
109 $filesToFindBySha1s = array_unique( array_values( $sha1s ) );
110 if ( $params[
'localonly'] ) {
111 $filesBySha1s = $this->repoGroup->getLocalRepo()->findBySha1s( $filesToFindBySha1s );
113 $filesBySha1s = $this->repoGroup->findBySha1s( $filesToFindBySha1s );
117 foreach ( $images as $image => $pageId ) {
118 if ( !isset( $sha1s[$image] ) ) {
121 $sha1 = $sha1s[$image];
122 $dupFiles = $filesBySha1s[$sha1];
123 if ( $params[
'dir'] ==
'descending' ) {
124 $dupFiles = array_reverse( $dupFiles );
127 foreach ( $dupFiles as $dupFile ) {
128 $dupName = $dupFile->getName();
129 if ( $image == $dupName && $dupFile->isLocal() ) {
132 if ( $skipUntilThisDup !==
false && $dupName < $skipUntilThisDup ) {
135 $skipUntilThisDup =
false;
136 if ( ++$count > $params[
'limit'] ) {
143 if ( $resultPageSet !==
null ) {
144 $titles[] = $dupFile->getTitle();
148 'timestamp' =>
wfTimestamp( TS_ISO_8601, $dupFile->getTimestamp() ),
149 'shared' => !$dupFile->isLocal(),
151 $uploader = $dupFile->getUploader( File::FOR_PUBLIC );
153 $r[
'user'] = $uploader->getName();
166 if ( $resultPageSet !==
null ) {
167 $resultPageSet->populateFromTitles( $titles );
190 'localonly' =>
false,
196 'action=query&titles=File:Albert_Einstein_Head.jpg&prop=duplicatefiles'
197 =>
'apihelp-query+duplicatefiles-example-simple',
198 'action=query&generator=allimages&prop=duplicatefiles'
199 =>
'apihelp-query+duplicatefiles-example-generated',
204 return 'https://www.mediawiki.org/wiki/Special:MyLanguage/API:Duplicatefiles';
wfTimestamp( $outputtype=TS_UNIX, $ts=0)
Get a timestamp string in one of various formats.
dieContinueUsageIf( $condition)
Die with the 'badcontinue' error.
const LIMIT_BIG1
Fast query, standard limit.
extractRequestParams( $options=[])
Using getAllowedParams(), this function makes an array of the values provided by the user,...
const PARAM_HELP_MSG
(string|array|Message) Specify an alternative i18n documentation message for this parameter.
const LIMIT_BIG2
Fast query, apihighlimits limit.
addPageSubItem( $pageId, $item, $elemname=null)
Same as addPageSubItems(), but one element of $data at a time.
A query module to list duplicates of the given file(s)
execute()
Evaluates the parameters, performs the requested query, and sets up the result.
executeGenerator( $resultPageSet)
Execute this module as a generator.
run( $resultPageSet=null)
getAllowedParams()
Returns an array of allowed parameters (parameter name) => (default value) or (parameter name) => (ar...
getCacheMode( $params)
Get the cache mode for the data generated by this module.
getExamplesMessages()
Returns usage examples for this module.
getHelpUrls()
Return links to more detailed help pages about the module.
__construct(ApiQuery $query, $moduleName, RepoGroup $repoGroup)
setContinueEnumParameter( $paramName, $paramValue)
Overridden to set the generator param if in generator mode.
getPageSet()
Get the PageSet object to work on.
This is the main query class.
Implements some public methods and some protected utility functions which are required by multiple ch...
getSha1()
Get the SHA-1 base 36 hash of the file.
Prioritized list of file repositories.
if(PHP_SAPI !='cli-server') if(!isset( $_SERVER['SCRIPT_FILENAME'])) $file
Item class for a filearchive table row.