mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/CategoryTree
synced 2024-11-27 17:51:00 +00:00
Simplify ApiCategoryTree::extractOptions
Change-Id: I98605b2580a995e37a8da1b88693b38bbd5b8013
This commit is contained in:
parent
9be6563cfa
commit
3252ddc115
|
@ -98,29 +98,17 @@ class ApiCategoryTree extends ApiBase {
|
||||||
$this->dieWithError( 'apierror-categorytree-invalidjson', 'invalidjson' );
|
$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 ) {
|
foreach ( $options as $option => $value ) {
|
||||||
if ( !is_scalar( $value ) && $value !== null ) {
|
if ( is_scalar( $value ) || $value === null ) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if ( $option === 'namespaces' && is_array( $value ) ) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
$this->dieWithError(
|
$this->dieWithError(
|
||||||
[ 'apierror-categorytree-invalidjson-option', $option ], 'invalidjson-option'
|
[ 'apierror-categorytree-invalidjson-option', $option ], 'invalidjson-option'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if ( $namespaces ) {
|
|
||||||
$options->namespaces = $namespaces;
|
|
||||||
}
|
|
||||||
|
|
||||||
return get_object_vars( $options );
|
return get_object_vars( $options );
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue