mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/CategoryTree
synced 2024-11-27 09:43:06 +00:00
Simplify ApiCategoryTree::extractOptions
Change-Id: I98605b2580a995e37a8da1b88693b38bbd5b8013
This commit is contained in:
parent
9be6563cfa
commit
3252ddc115
|
@ -98,28 +98,16 @@ class ApiCategoryTree extends ApiBase {
|
|||
$this->dieWithError( 'apierror-categorytree-invalidjson', 'invalidjson' );
|
||||
}
|
||||
|
||||
$namespaces = $options->namespaces ?? null;
|
||||
|
||||
if ( $namespaces !== null ) {
|
||||
if ( !is_scalar( $namespaces ) && !is_array( $namespaces ) ) {
|
||||
$this->dieWithError(
|
||||
[ 'apierror-categorytree-invalidjson-option', 'namespaces' ], 'invalidjson-option'
|
||||
);
|
||||
}
|
||||
// Don't recheck this in the loop below
|
||||
unset( $options->namespaces );
|
||||
}
|
||||
|
||||
foreach ( $options as $option => $value ) {
|
||||
if ( !is_scalar( $value ) && $value !== null ) {
|
||||
$this->dieWithError(
|
||||
[ 'apierror-categorytree-invalidjson-option', $option ], 'invalidjson-option'
|
||||
);
|
||||
if ( is_scalar( $value ) || $value === null ) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if ( $namespaces ) {
|
||||
$options->namespaces = $namespaces;
|
||||
if ( $option === 'namespaces' && is_array( $value ) ) {
|
||||
continue;
|
||||
}
|
||||
$this->dieWithError(
|
||||
[ 'apierror-categorytree-invalidjson-option', $option ], 'invalidjson-option'
|
||||
);
|
||||
}
|
||||
|
||||
return get_object_vars( $options );
|
||||
|
|
Loading…
Reference in a new issue