Merge "Fix Ifb93e49b"
[lhc/web/wiklou.git] / includes / api / ApiQueryAllImages.php
index e6a0194..e24b162 100644 (file)
@@ -41,8 +41,8 @@ class ApiQueryAllImages extends ApiQueryGeneratorBase {
        }
 
        /**
-        * Override parent method to make sure to make sure the repo's DB is used
-        * which may not necesarilly be the same as the local DB.
+        * Override parent method to make sure the repo's DB is used
+        * which may not necessarily be the same as the local DB.
         *
         * TODO: allow querying non-local repos.
         * @return DatabaseBase
@@ -94,7 +94,7 @@ class ApiQueryAllImages extends ApiQueryGeneratorBase {
                $this->addFields( LocalFile::selectFields() );
 
                $ascendingOrder = true;
-               if ( $params['dir'] == 'descending' || $params['dir'] == 'older') {
+               if ( $params['dir'] == 'descending' || $params['dir'] == 'older' ) {
                        $ascendingOrder = false;
                }
 
@@ -113,10 +113,7 @@ class ApiQueryAllImages extends ApiQueryGeneratorBase {
                        // Pagination
                        if ( !is_null( $params['continue'] ) ) {
                                $cont = explode( '|', $params['continue'] );
-                               if ( count( $cont ) != 1 ) {
-                                       $this->dieUsage( 'Invalid continue param. You should pass the ' .
-                                               'original value returned by the previous query', '_badcontinue' );
-                               }
+                               $this->dieContinueUsageIf( count( $cont ) != 1 );
                                $op = ( $ascendingOrder ? '>' : '<' );
                                $continueFrom = $db->addQuotes( $cont[0] );
                                $this->addWhere( "img_name $op= $continueFrom" );
@@ -175,12 +172,13 @@ class ApiQueryAllImages extends ApiQueryGeneratorBase {
 
                $sha1 = false;
                if ( isset( $params['sha1'] ) ) {
-                       if ( !$this->validateSha1Hash( $params['sha1'] ) ) {
+                       $sha1 = strtolower( $params['sha1'] );
+                       if ( !$this->validateSha1Hash( $sha1 ) ) {
                                $this->dieUsage( 'The SHA1 hash provided is not valid', 'invalidsha1hash' );
                        }
-                       $sha1 = wfBaseConvert( $params['sha1'], 16, 36, 31 );
+                       $sha1 = wfBaseConvert( $sha1, 16, 36, 31 );
                } elseif ( isset( $params['sha1base36'] ) ) {
-                       $sha1 = $params['sha1base36'];
+                       $sha1 = strtolower( $params['sha1base36'] );
                        if ( !$this->validateSha1Base36Hash( $sha1 ) ) {
                                $this->dieUsage( 'The SHA1Base36 hash provided is not valid', 'invalidsha1base36hash' );
                        }
@@ -384,7 +382,6 @@ class ApiQueryAllImages extends ApiQueryGeneratorBase {
                        array( 'code' => 'mimesearchdisabled', 'info' => 'MIME search disabled in Miser Mode' ),
                        array( 'code' => 'invalidsha1hash', 'info' => 'The SHA1 hash provided is not valid' ),
                        array( 'code' => 'invalidsha1base36hash', 'info' => 'The SHA1Base36 hash provided is not valid' ),
-                       array( 'code' => '_badcontinue', 'info' => 'Invalid continue param. You should pass the original value returned by the previous query' ),
                ) );
        }
 
@@ -408,8 +405,4 @@ class ApiQueryAllImages extends ApiQueryGeneratorBase {
        public function getHelpUrls() {
                return 'https://www.mediawiki.org/wiki/API:Allimages';
        }
-
-       public function getVersion() {
-               return __CLASS__ . ': $Id$';
-       }
 }