44 parent::__construct( $query, $moduleName,
'df' );
45 $this->repoGroup = $repoGroup;
57 $this->run( $resultPageSet );
63 private function run( $resultPageSet =
null ) {
65 $namespaces = $this->
getPageSet()->getGoodAndMissingTitlesByNamespace();
66 if ( empty( $namespaces[
NS_FILE] ) ) {
71 if ( $params[
'dir'] ==
'descending' ) {
72 $images = array_reverse( $images );
75 $skipUntilThisDup =
false;
76 if ( isset( $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 ) {
104 $sha1s[$file->getName()] = $file->getSha1();
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 );
174 ParamValidator::PARAM_DEFAULT => 10,
175 ParamValidator::PARAM_TYPE =>
'limit',
176 IntegerDef::PARAM_MIN => 1,
184 ParamValidator::PARAM_DEFAULT =>
'ascending',
185 ParamValidator::PARAM_TYPE => [
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';
209class_alias( ApiQueryDuplicateFiles::class,
'ApiQueryDuplicateFiles' );
wfTimestamp( $outputtype=TS_UNIX, $ts=0)
Get a timestamp string in one of various formats.