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'] ) ) {
80 $fromImage = $cont[0];
81 $skipUntilThisDup = $cont[1];
83 foreach ( $images as $image => $pageId ) {
84 if ( $image < $fromImage ) {
85 unset( $images[$image] );
92 $filesToFind = array_keys( $images );
93 if ( $params[
'localonly'] ) {
94 $files = $this->repoGroup->getLocalRepo()->findFiles( $filesToFind );
96 $files = $this->repoGroup->findFiles( $filesToFind );
104 foreach ( $files as
$file ) {
111 $filesToFindBySha1s = array_unique( array_values( $sha1s ) );
112 if ( $params[
'localonly'] ) {
113 $filesBySha1s = $this->repoGroup->getLocalRepo()->findBySha1s( $filesToFindBySha1s );
115 $filesBySha1s = $this->repoGroup->findBySha1s( $filesToFindBySha1s );
119 foreach ( $images as $image => $pageId ) {
120 if ( !isset( $sha1s[$image] ) ) {
123 $sha1 = $sha1s[$image];
124 $dupFiles = $filesBySha1s[$sha1];
125 if ( $params[
'dir'] ==
'descending' ) {
126 $dupFiles = array_reverse( $dupFiles );
129 foreach ( $dupFiles as $dupFile ) {
130 $dupName = $dupFile->getName();
131 if ( $image == $dupName && $dupFile->isLocal() ) {
134 if ( $skipUntilThisDup !==
false && $dupName < $skipUntilThisDup ) {
137 $skipUntilThisDup =
false;
138 if ( ++$count > $params[
'limit'] ) {
145 if ( $resultPageSet !==
null ) {
146 $titles[] = $dupFile->getTitle();
150 'timestamp' =>
wfTimestamp( TS_ISO_8601, $dupFile->getTimestamp() ),
151 'shared' => !$dupFile->isLocal(),
155 $r[
'user'] = $uploader->getName();
168 if ( $resultPageSet !==
null ) {
169 $resultPageSet->populateFromTitles( $titles );
176 ParamValidator::PARAM_DEFAULT => 10,
177 ParamValidator::PARAM_TYPE =>
'limit',
178 IntegerDef::PARAM_MIN => 1,
186 ParamValidator::PARAM_DEFAULT =>
'ascending',
187 ParamValidator::PARAM_TYPE => [
192 'localonly' =>
false,
198 'action=query&titles=File:Albert_Einstein_Head.jpg&prop=duplicatefiles'
199 =>
'apihelp-query+duplicatefiles-example-simple',
200 'action=query&generator=allimages&prop=duplicatefiles'
201 =>
'apihelp-query+duplicatefiles-example-generated',
206 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.
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.
Prioritized list of file repositories.
if(PHP_SAPI !='cli-server') if(!isset( $_SERVER['SCRIPT_FILENAME'])) $file
Item class for a filearchive table row.