46 parent::__construct( $query, $moduleName,
'df' );
47 $this->repoGroup = $repoGroup;
59 $this->run( $resultPageSet );
65 private function run( $resultPageSet =
null ) {
67 $namespaces = $this->
getPageSet()->getGoodAndMissingTitlesByNamespace();
68 if ( empty( $namespaces[
NS_FILE] ) ) {
73 if ( $params[
'dir'] ==
'descending' ) {
74 $images = array_reverse( $images );
77 $skipUntilThisDup =
false;
78 if ( isset( $params[
'continue'] ) ) {
79 $cont = explode(
'|', $params[
'continue'] );
81 $fromImage = $cont[0];
82 $skipUntilThisDup = $cont[1];
84 foreach ( $images as $image => $pageId ) {
85 if ( $image < $fromImage ) {
86 unset( $images[$image] );
93 $filesToFind = array_keys( $images );
94 if ( $params[
'localonly'] ) {
95 $files = $this->repoGroup->getLocalRepo()->findFiles( $filesToFind );
97 $files = $this->repoGroup->findFiles( $filesToFind );
105 foreach ( $files as
$file ) {
112 $filesToFindBySha1s = array_unique( array_values( $sha1s ) );
113 if ( $params[
'localonly'] ) {
114 $filesBySha1s = $this->repoGroup->getLocalRepo()->findBySha1s( $filesToFindBySha1s );
116 $filesBySha1s = $this->repoGroup->findBySha1s( $filesToFindBySha1s );
120 foreach ( $images as $image => $pageId ) {
121 if ( !isset( $sha1s[$image] ) ) {
124 $sha1 = $sha1s[$image];
125 $dupFiles = $filesBySha1s[$sha1];
126 if ( $params[
'dir'] ==
'descending' ) {
127 $dupFiles = array_reverse( $dupFiles );
130 foreach ( $dupFiles as $dupFile ) {
131 $dupName = $dupFile->getName();
132 if ( $image == $dupName && $dupFile->isLocal() ) {
135 if ( $skipUntilThisDup !==
false && $dupName < $skipUntilThisDup ) {
138 $skipUntilThisDup =
false;
139 if ( ++$count > $params[
'limit'] ) {
146 if ( $resultPageSet !==
null ) {
147 $titles[] = $dupFile->getTitle();
151 'timestamp' =>
wfTimestamp( TS_ISO_8601, $dupFile->getTimestamp() ),
152 'shared' => !$dupFile->isLocal(),
154 $uploader = $dupFile->getUploader( File::FOR_PUBLIC );
156 $r[
'user'] = $uploader->getName();
169 if ( $resultPageSet !==
null ) {
170 $resultPageSet->populateFromTitles( $titles );
177 ParamValidator::PARAM_DEFAULT => 10,
178 ParamValidator::PARAM_TYPE =>
'limit',
179 IntegerDef::PARAM_MIN => 1,
187 ParamValidator::PARAM_DEFAULT =>
'ascending',
188 ParamValidator::PARAM_TYPE => [
193 'localonly' =>
false,
199 'action=query&titles=File:Albert_Einstein_Head.jpg&prop=duplicatefiles'
200 =>
'apihelp-query+duplicatefiles-example-simple',
201 'action=query&generator=allimages&prop=duplicatefiles'
202 =>
'apihelp-query+duplicatefiles-example-generated',
207 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.
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.