X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=blobdiff_plain;f=includes%2Fapi%2FApiQueryCategoryMembers.php;h=3a8847c3396484760c603509daeea609bd1793d6;hp=4865ad56f9169e114990c9ef095716e4c8373f50;hb=49748181dd56ec97e7ba7c13e684a16abceb3cc0;hpb=57eaa2bf04ce1b48bd89c10defe4de5b7d31f047 diff --git a/includes/api/ApiQueryCategoryMembers.php b/includes/api/ApiQueryCategoryMembers.php index 4865ad56f9..3a8847c339 100644 --- a/includes/api/ApiQueryCategoryMembers.php +++ b/includes/api/ApiQueryCategoryMembers.php @@ -53,7 +53,7 @@ class ApiQueryCategoryMembers extends ApiQueryGeneratorBase { */ private function validateHexSortkey( $hexSortkey ) { // A hex sortkey has an unbound number of 2 letter pairs - return preg_match( '/^(?:[a-fA-F0-9]{2})*$/D', $hexSortkey ); + return (bool)preg_match( '/^(?:[a-fA-F0-9]{2})*$/D', $hexSortkey ); } /** @@ -65,7 +65,7 @@ class ApiQueryCategoryMembers extends ApiQueryGeneratorBase { $categoryTitle = $this->getTitleOrPageId( $params )->getTitle(); if ( $categoryTitle->getNamespace() != NS_CATEGORY ) { - $this->dieUsage( 'The category name you entered is not valid', 'invalidcategory' ); + $this->dieWithError( 'apierror-invalidcategory' ); } $prop = array_flip( $params['prop'] ); @@ -153,7 +153,8 @@ class ApiQueryCategoryMembers extends ApiQueryGeneratorBase { $startsortkey = Collation::singleton()->getSortKey( $params['startsortkeyprefix'] ); } elseif ( $params['starthexsortkey'] !== null ) { if ( !$this->validateHexSortkey( $params['starthexsortkey'] ) ) { - $this->dieUsage( 'The starthexsortkey provided is not valid', 'bad_starthexsortkey' ); + $encParamName = $this->encodeParamName( 'starthexsortkey' ); + $this->dieWithError( [ 'apierror-badparameter', $encParamName ], "badvalue_$encParamName" ); } $startsortkey = hex2bin( $params['starthexsortkey'] ); } else { @@ -163,7 +164,8 @@ class ApiQueryCategoryMembers extends ApiQueryGeneratorBase { $endsortkey = Collation::singleton()->getSortKey( $params['endsortkeyprefix'] ); } elseif ( $params['endhexsortkey'] !== null ) { if ( !$this->validateHexSortkey( $params['endhexsortkey'] ) ) { - $this->dieUsage( 'The endhexsortkey provided is not valid', 'bad_endhexsortkey' ); + $encParamName = $this->encodeParamName( 'endhexsortkey' ); + $this->dieWithError( [ 'apierror-badparameter', $encParamName ], "badvalue_$encParamName" ); } $endsortkey = hex2bin( $params['endhexsortkey'] ); } else {