*/
private function validateHexSortkey( $hexSortkey ) {
// A hex sortkey has an unbound number of 2 letter pairs
*/
private function validateHexSortkey( $hexSortkey ) {
// A hex sortkey has an unbound number of 2 letter pairs
$categoryTitle = $this->getTitleOrPageId( $params )->getTitle();
if ( $categoryTitle->getNamespace() != NS_CATEGORY ) {
$categoryTitle = $this->getTitleOrPageId( $params )->getTitle();
if ( $categoryTitle->getNamespace() != NS_CATEGORY ) {
- $this->addFields( array( 'cl_from', 'cl_sortkey', 'cl_type', 'page_namespace', 'page_title' ) );
+ $this->addFields( [ 'cl_from', 'cl_sortkey', 'cl_type', 'page_namespace', 'page_title' ] );
$this->addFieldsIf( 'page_id', $fld_ids );
$this->addFieldsIf( 'cl_sortkey_prefix', $fld_sortkeyprefix );
} else {
$this->addFields( $resultPageSet->getPageTableFields() ); // will include page_ id, ns, title
$this->addFieldsIf( 'page_id', $fld_ids );
$this->addFieldsIf( 'cl_sortkey_prefix', $fld_sortkeyprefix );
} else {
$this->addFields( $resultPageSet->getPageTableFields() ); // will include page_ id, ns, title
$this->addWhereFld( 'cl_to', $categoryTitle->getDBkey() );
$queryTypes = $params['type'];
$this->addWhereFld( 'cl_to', $categoryTitle->getDBkey() );
$queryTypes = $params['type'];
// Scanning large datasets for rare categories sucks, and I already told
// how to have efficient subcategory access :-) ~~~~ (oh well, domas)
// Scanning large datasets for rare categories sucks, and I already told
// how to have efficient subcategory access :-) ~~~~ (oh well, domas)
if ( $this->getConfig()->get( 'MiserMode' ) ) {
$miser_ns = $params['namespace'];
} else {
$this->addWhereFld( 'page_namespace', $params['namespace'] );
}
if ( $this->getConfig()->get( 'MiserMode' ) ) {
$miser_ns = $params['namespace'];
} else {
$this->addWhereFld( 'page_namespace', $params['namespace'] );
}
- $dir = in_array( $params['dir'], array( 'asc', 'ascending', 'newer' ) ) ? 'newer' : 'older';
+ $dir = in_array( $params['dir'], [ 'asc', 'ascending', 'newer' ] ) ? 'newer' : 'older';
if ( $params['sort'] == 'timestamp' ) {
$this->addTimestampWhereRange( 'cl_timestamp',
if ( $params['sort'] == 'timestamp' ) {
$this->addTimestampWhereRange( 'cl_timestamp',
// Add a WHERE clause for sortkey and from
$this->dieContinueUsageIf( !$this->validateHexSortkey( $cont[1] ) );
// Add a WHERE clause for sortkey and from
$this->dieContinueUsageIf( !$this->validateHexSortkey( $cont[1] ) );
$from = intval( $cont[2] );
$op = $dir == 'newer' ? '>' : '<';
// $contWhere is used further down
$from = intval( $cont[2] );
$op = $dir == 'newer' ? '>' : '<';
// $contWhere is used further down
$this->addWhereRange( 'cl_from', $dir, null, null );
} else {
if ( $params['startsortkeyprefix'] !== null ) {
$this->addWhereRange( 'cl_from', $dir, null, null );
} else {
if ( $params['startsortkeyprefix'] !== null ) {
} elseif ( $params['starthexsortkey'] !== null ) {
if ( !$this->validateHexSortkey( $params['starthexsortkey'] ) ) {
} 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" );
} elseif ( $params['endhexsortkey'] !== null ) {
if ( !$this->validateHexSortkey( $params['endhexsortkey'] ) ) {
} 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" );
// inconsistencies between ORDER BY cl_type and
// WHERE cl_type >= 'foo' making proper paging impossible
// and unindexed.
// inconsistencies between ORDER BY cl_type and
// WHERE cl_type >= 'foo' making proper paging impossible
// and unindexed.
if ( $first && $contWhere ) {
// Continuation condition. Only added to the
// first query, otherwise we'll skip things
$extraConds[] = $contWhere;
}
if ( $first && $contWhere ) {
// Continuation condition. Only added to the
// first query, otherwise we'll skip things
$extraConds[] = $contWhere;
}
$rows = array_merge( $rows, iterator_to_array( $res ) );
if ( count( $rows ) >= $limit + 1 ) {
break;
$rows = array_merge( $rows, iterator_to_array( $res ) );
if ( count( $rows ) >= $limit + 1 ) {
break;
ApiBase::PARAM_DFLT => 'ids|title',
ApiBase::PARAM_ISMULTI => true,
ApiBase::PARAM_DFLT => 'ids|title',
ApiBase::PARAM_ISMULTI => true,
ApiBase::PARAM_ISMULTI => true,
ApiBase::PARAM_TYPE => 'namespace',
ApiBase::PARAM_ISMULTI => true,
ApiBase::PARAM_TYPE => 'namespace',
ApiBase::PARAM_ISMULTI => true,
ApiBase::PARAM_DFLT => 'page|subcat|file',
ApiBase::PARAM_ISMULTI => true,
ApiBase::PARAM_DFLT => 'page|subcat|file',
ApiBase::PARAM_TYPE => 'limit',
ApiBase::PARAM_DFLT => 10,
ApiBase::PARAM_MIN => 1,
ApiBase::PARAM_MAX => ApiBase::LIMIT_BIG1,
ApiBase::PARAM_MAX2 => ApiBase::LIMIT_BIG2
ApiBase::PARAM_TYPE => 'limit',
ApiBase::PARAM_DFLT => 10,
ApiBase::PARAM_MIN => 1,
ApiBase::PARAM_MAX => ApiBase::LIMIT_BIG1,
ApiBase::PARAM_MAX2 => ApiBase::LIMIT_BIG2
'starthexsortkey' => null,
'endhexsortkey' => null,
'startsortkeyprefix' => null,
'endsortkeyprefix' => null,
'starthexsortkey' => null,
'endhexsortkey' => null,
'startsortkeyprefix' => null,
'endsortkeyprefix' => null,
'action=query&list=categorymembers&cmtitle=Category:Physics'
=> 'apihelp-query+categorymembers-example-simple',
'action=query&generator=categorymembers&gcmtitle=Category:Physics&prop=info'
=> 'apihelp-query+categorymembers-example-generator',
'action=query&list=categorymembers&cmtitle=Category:Physics'
=> 'apihelp-query+categorymembers-example-simple',
'action=query&generator=categorymembers&gcmtitle=Category:Physics&prop=info'
=> 'apihelp-query+categorymembers-example-generator',