X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fapi%2FApiQueryAllImages.php;h=22561a9bcebe05e6bcf529006adefd33b1588314;hb=ac8f144c042ae9d06f2baeb3c713afcc2a9a778a;hp=8734f380bb6a696079b5648bfe6b9498988181e5;hpb=163282a24c6201b25eb0ecdf753ffa6ad689ed0f;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/api/ApiQueryAllImages.php b/includes/api/ApiQueryAllImages.php index 8734f380bb..22561a9bce 100644 --- a/includes/api/ApiQueryAllImages.php +++ b/includes/api/ApiQueryAllImages.php @@ -64,11 +64,7 @@ class ApiQueryAllImages extends ApiQueryGeneratorBase { */ public function executeGenerator( $resultPageSet ) { if ( $resultPageSet->isResolvingRedirects() ) { - $this->dieUsage( - 'Use "gaifilterredir=nonredirects" option instead of "redirects" ' . - 'when using allimages as a generator', - 'params' - ); + $this->dieWithError( 'apierror-allimages-redirect', 'invalidparammix' ); } $this->run( $resultPageSet ); @@ -81,10 +77,7 @@ class ApiQueryAllImages extends ApiQueryGeneratorBase { private function run( $resultPageSet = null ) { $repo = $this->mRepo; if ( !$repo instanceof LocalRepo ) { - $this->dieUsage( - 'Local file repository does not support querying all images', - 'unsupportedrepo' - ); + $this->dieWithError( 'apierror-unsupportedrepo' ); } $prefix = $this->getModulePrefix(); @@ -109,16 +102,24 @@ class ApiQueryAllImages extends ApiQueryGeneratorBase { $disallowed = [ 'start', 'end', 'user' ]; foreach ( $disallowed as $pname ) { if ( isset( $params[$pname] ) ) { - $this->dieUsage( - "Parameter '{$prefix}{$pname}' can only be used with {$prefix}sort=timestamp", - 'badparams' + $this->dieWithError( + [ + 'apierror-invalidparammix-mustusewith', + "{$prefix}{$pname}", + "{$prefix}sort=timestamp" + ], + 'invalidparammix' ); } } if ( $params['filterbots'] != 'all' ) { - $this->dieUsage( - "Parameter '{$prefix}filterbots' can only be used with {$prefix}sort=timestamp", - 'badparams' + $this->dieWithError( + [ + 'apierror-invalidparammix-mustusewith', + "{$prefix}filterbots", + "{$prefix}sort=timestamp" + ], + 'invalidparammix' ); } @@ -146,18 +147,21 @@ class ApiQueryAllImages extends ApiQueryGeneratorBase { $disallowed = [ 'from', 'to', 'prefix' ]; foreach ( $disallowed as $pname ) { if ( isset( $params[$pname] ) ) { - $this->dieUsage( - "Parameter '{$prefix}{$pname}' can only be used with {$prefix}sort=name", - 'badparams' + $this->dieWithError( + [ + 'apierror-invalidparammix-mustusewith', + "{$prefix}{$pname}", + "{$prefix}sort=name" + ], + 'invalidparammix' ); } } if ( !is_null( $params['user'] ) && $params['filterbots'] != 'all' ) { // Since filterbots checks if each user has the bot right, it // doesn't make sense to use it with user - $this->dieUsage( - "Parameters '{$prefix}user' and '{$prefix}filterbots' cannot be used together", - 'badparams' + $this->dieWithError( + [ 'apierror-invalidparammix-cannotusewith', "{$prefix}user", "{$prefix}filterbots" ] ); } @@ -193,7 +197,8 @@ class ApiQueryAllImages extends ApiQueryGeneratorBase { 'LEFT JOIN', [ 'ug_group' => User::getGroupsWithPermission( 'bot' ), - 'ug_user = img_user' + 'ug_user = img_user', + 'ug_expiry IS NULL OR ug_expiry >=' . $db->addQuotes( $db->timestamp() ) ] ] ] ); $groupCond = ( $params['filterbots'] == 'nobots' ? 'NULL' : 'NOT NULL' ); @@ -214,13 +219,13 @@ class ApiQueryAllImages extends ApiQueryGeneratorBase { if ( isset( $params['sha1'] ) ) { $sha1 = strtolower( $params['sha1'] ); if ( !$this->validateSha1Hash( $sha1 ) ) { - $this->dieUsage( 'The SHA1 hash provided is not valid', 'invalidsha1hash' ); + $this->dieWithError( 'apierror-invalidsha1hash' ); } $sha1 = Wikimedia\base_convert( $sha1, 16, 36, 31 ); } elseif ( isset( $params['sha1base36'] ) ) { $sha1 = strtolower( $params['sha1base36'] ); if ( !$this->validateSha1Base36Hash( $sha1 ) ) { - $this->dieUsage( 'The SHA1Base36 hash provided is not valid', 'invalidsha1base36hash' ); + $this->dieWithError( 'apierror-invalidsha1base36hash' ); } } if ( $sha1 ) { @@ -229,7 +234,7 @@ class ApiQueryAllImages extends ApiQueryGeneratorBase { if ( !is_null( $params['mime'] ) ) { if ( $this->getConfig()->get( 'MiserMode' ) ) { - $this->dieUsage( 'MIME search disabled in Miser Mode', 'mimesearchdisabled' ); + $this->dieWithError( 'apierror-mimesearchdisabled' ); } $mimeConds = [];