33 parent::__construct( $query, $moduleName,
'df' );
45 $this->
run( $resultPageSet );
51 private function run( $resultPageSet =
null ) {
53 $namespaces = $this->
getPageSet()->getGoodAndMissingTitlesByNamespace();
54 if ( empty( $namespaces[
NS_FILE] ) ) {
59 if ( $params[
'dir'] ==
'descending' ) {
60 $images = array_reverse( $images );
63 $skipUntilThisDup =
false;
64 if ( isset( $params[
'continue'] ) ) {
65 $cont = explode(
'|', $params[
'continue'] );
67 $fromImage = $cont[0];
68 $skipUntilThisDup = $cont[1];
70 foreach ( $images as $image => $pageId ) {
71 if ( $image < $fromImage ) {
72 unset( $images[$image] );
79 $filesToFind = array_keys( $images );
80 $repoGroup = MediaWikiServices::getInstance()->getRepoGroup();
81 if ( $params[
'localonly'] ) {
82 $files = $repoGroup->getLocalRepo()->findFiles( $filesToFind );
84 $files = $repoGroup->findFiles( $filesToFind );
92 foreach ( $files as
$file ) {
99 $filesToFindBySha1s = array_unique( array_values( $sha1s ) );
100 if ( $params[
'localonly'] ) {
101 $filesBySha1s = $repoGroup->getLocalRepo()->findBySha1s( $filesToFindBySha1s );
103 $filesBySha1s = $repoGroup->findBySha1s( $filesToFindBySha1s );
107 foreach ( $images as $image => $pageId ) {
108 if ( !isset( $sha1s[$image] ) ) {
111 $sha1 = $sha1s[$image];
112 $dupFiles = $filesBySha1s[$sha1];
113 if ( $params[
'dir'] ==
'descending' ) {
114 $dupFiles = array_reverse( $dupFiles );
117 foreach ( $dupFiles as $dupFile ) {
118 $dupName = $dupFile->getName();
119 if ( $image == $dupName && $dupFile->isLocal() ) {
122 if ( $skipUntilThisDup !==
false && $dupName < $skipUntilThisDup ) {
125 $skipUntilThisDup =
false;
126 if ( ++$count > $params[
'limit'] ) {
133 if ( $resultPageSet !==
null ) {
134 $titles[] = $dupFile->getTitle();
138 'user' => $dupFile->getUser(
'text' ),
139 'timestamp' =>
wfTimestamp( TS_ISO_8601, $dupFile->getTimestamp() ),
140 'shared' => !$dupFile->isLocal(),
153 if ( $resultPageSet !==
null ) {
154 $resultPageSet->populateFromTitles( $titles );
177 'localonly' =>
false,
183 'action=query&titles=File:Albert_Einstein_Head.jpg&prop=duplicatefiles'
184 =>
'apihelp-query+duplicatefiles-example-simple',
185 'action=query&generator=allimages&prop=duplicatefiles'
186 =>
'apihelp-query+duplicatefiles-example-generated',
191 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)
__construct(ApiQuery $query, $moduleName)
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.
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.
if(PHP_SAPI !='cli-server') if(!isset( $_SERVER['SCRIPT_FILENAME'])) $file
Item class for a filearchive table row.