*/
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 );
}
/**
$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'] );
$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 {
$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 {
}
public function getHelpUrls() {
- return 'https://www.mediawiki.org/wiki/API:Categorymembers';
+ return 'https://www.mediawiki.org/wiki/Special:MyLanguage/API:Categorymembers';
}
}