$params = $this->extractRequestParams();
// Figure out expiry times from the input
- // $params['expiry'] may not be set in subclasses
+ // $params['expiry'] is not set in CentralAuth's ApiGlobalUserRights subclass
if ( isset( $params['expiry'] ) ) {
$expiry = (array)$params['expiry'];
} else {
$expiry = [ 'infinity' ];
}
- if ( count( $expiry ) !== count( $params['add'] ) ) {
+ $add = (array)$params['add'];
+ if ( !$add ) {
+ $expiry = [];
+ } elseif ( count( $expiry ) !== count( $add ) ) {
if ( count( $expiry ) === 1 ) {
- $expiry = array_fill( 0, count( $params['add'] ), $expiry[0] );
+ $expiry = array_fill( 0, count( $add ), $expiry[0] );
} else {
$this->dieWithError( [
'apierror-toofewexpiries',
count( $expiry ),
- count( $params['add'] )
+ count( $add )
] );
}
}
// Validate the expiries
$groupExpiries = [];
foreach ( $expiry as $index => $expiryValue ) {
- $group = $params['add'][$index];
+ $group = $add[$index];
$groupExpiries[$group] = UserrightsPage::expiryToTimestamp( $expiryValue );
if ( $groupExpiries[$group] === false ) {
$r['user'] = $user->getName();
$r['userid'] = $user->getId();
list( $r['added'], $r['removed'] ) = $form->doSaveUserGroups(
- $user, (array)$params['add'], (array)$params['remove'],
+ $user, (array)$add, (array)$params['remove'],
$params['reason'], $tags, $groupExpiries
);
ApiBase::PARAM_ISMULTI => true
],
];
+ // CentralAuth's ApiGlobalUserRights subclass can't handle expiries
if ( !$this->getUserRightsPage()->canProcessExpiries() ) {
unset( $a['expiry'] );
}