45 parent::__construct( $query, $moduleName,
'df' );
46 $this->repoGroup = $repoGroup;
58 $this->
run( $resultPageSet );
64 private function run( $resultPageSet =
null ) {
66 $namespaces = $this->
getPageSet()->getGoodAndMissingTitlesByNamespace();
67 if ( empty( $namespaces[
NS_FILE] ) ) {
72 if (
$params[
'dir'] ==
'descending' ) {
73 $images = array_reverse( $images );
76 $skipUntilThisDup =
false;
77 if ( isset(
$params[
'continue'] ) ) {
79 $fromImage = $cont[0];
80 $skipUntilThisDup = $cont[1];
82 foreach ( $images as $image => $pageId ) {
83 if ( $image < $fromImage ) {
84 unset( $images[$image] );
91 $filesToFind = array_keys( $images );
93 $files = $this->repoGroup->getLocalRepo()->findFiles( $filesToFind );
95 $files = $this->repoGroup->findFiles( $filesToFind );
103 foreach ( $files as $file ) {
105 $sha1s[$file->getName()] = $file->
getSha1();
110 $filesToFindBySha1s = array_unique( array_values( $sha1s ) );
112 $filesBySha1s = $this->repoGroup->getLocalRepo()->findBySha1s( $filesToFindBySha1s );
114 $filesBySha1s = $this->repoGroup->findBySha1s( $filesToFindBySha1s );
118 foreach ( $images as $image => $pageId ) {
119 if ( !isset( $sha1s[$image] ) ) {
122 $sha1 = $sha1s[$image];
123 $dupFiles = $filesBySha1s[$sha1];
124 if (
$params[
'dir'] ==
'descending' ) {
125 $dupFiles = array_reverse( $dupFiles );
128 foreach ( $dupFiles as $dupFile ) {
129 $dupName = $dupFile->getName();
130 if ( $image == $dupName && $dupFile->isLocal() ) {
133 if ( $skipUntilThisDup !==
false && $dupName < $skipUntilThisDup ) {
136 $skipUntilThisDup =
false;
137 if ( ++$count >
$params[
'limit'] ) {
144 if ( $resultPageSet !==
null ) {
145 $titles[] = $dupFile->getTitle();
149 'timestamp' =>
wfTimestamp( TS_ISO_8601, $dupFile->getTimestamp() ),
150 'shared' => !$dupFile->isLocal(),
152 $uploader = $dupFile->getUploader( File::FOR_PUBLIC );
154 $r[
'user'] = $uploader->getName();
167 if ( $resultPageSet !==
null ) {
168 $resultPageSet->populateFromTitles( $titles );
175 ParamValidator::PARAM_DEFAULT => 10,
176 ParamValidator::PARAM_TYPE =>
'limit',
177 IntegerDef::PARAM_MIN => 1,
185 ParamValidator::PARAM_DEFAULT =>
'ascending',
186 ParamValidator::PARAM_TYPE => [
191 'localonly' =>
false,
197 'action=query&titles=File:Albert_Einstein_Head.jpg&prop=duplicatefiles'
198 =>
'apihelp-query+duplicatefiles-example-simple',
199 'action=query&generator=allimages&prop=duplicatefiles'
200 =>
'apihelp-query+duplicatefiles-example-generated',
205 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.
array $params
The job parameters.
parseContinueParamOrDie(string $continue, array $types)
Parse the 'continue' parameter in the usual format and validate the types of each part,...
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.
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.