Merge "Maintenance script to check LESS files for validity"
[lhc/web/wiklou.git] / includes / api / ApiQueryImageInfo.php
index 40041d8..0ea2868 100644 (file)
@@ -82,12 +82,17 @@ class ApiQueryImageInfo extends ApiQueryBase {
                                $start = $title === $fromTitle ? $fromTimestamp : $params['start'];
 
                                if ( !isset( $images[$title] ) ) {
-                                       $result->addValue(
-                                               array( 'query', 'pages', intval( $pageId ) ),
-                                               'imagerepository', ''
-                                       );
-                                       // The above can't fail because it doesn't increase the result size
-                                       continue;
+                                       if ( isset( $prop['uploadwarning'] ) ) {
+                                               // Uploadwarning needs info about non-existing files
+                                               $images[$title] = wfLocalFile( $title );
+                                       } else {
+                                               $result->addValue(
+                                                       array( 'query', 'pages', intval( $pageId ) ),
+                                                       'imagerepository', ''
+                                               );
+                                               // The above can't fail because it doesn't increase the result size
+                                               continue;
+                                       }
                                }
 
                                /** @var $img File */
@@ -358,6 +363,7 @@ class ApiQueryImageInfo extends ApiQueryBase {
                $mediatype = isset( $prop['mediatype'] );
                $archive = isset( $prop['archivename'] );
                $bitdepth = isset( $prop['bitdepth'] );
+               $uploadwarning = isset( $prop['uploadwarning'] );
 
                if ( ( $url || $sha1 || $meta || $mime || $mediatype || $archive || $bitdepth )
                                && $file->isDeleted( File::DELETED_FILE ) ) {
@@ -427,6 +433,10 @@ class ApiQueryImageInfo extends ApiQueryBase {
                        $vals['bitdepth'] = $file->getBitDepth();
                }
 
+               if ( $uploadwarning ) {
+                       $vals['html'] = SpecialUpload::getExistsWarning( UploadBase::getExistsWarning( $file ) );
+               }
+
                return $vals;
        }
 
@@ -556,6 +566,7 @@ class ApiQueryImageInfo extends ApiQueryBase {
                        'metadata' =>       ' metadata      - Lists Exif metadata for the version of the image',
                        'archivename' =>    ' archivename   - Adds the file name of the archive version for non-latest versions',
                        'bitdepth' =>       ' bitdepth      - Adds the bit depth of the version',
+                       'uploadwarning' =>  ' uploadwarning - Used by the Special:Upload page to get information about an existing file. Not intended for use outside MediaWiki core',
                );
        }