// If change tagging was requested, check that the user is allowed to tag,
// and the tags are valid
- if ( count( $params['tags'] ) ) {
+ if ( $params['tags'] ) {
$tagStatus = ChangeTags::canAddTagsAccompanyingChange( $params['tags'], $user );
if ( !$tagStatus->isOK() ) {
$this->dieStatus( $tagStatus );
}
// Apply change tags
- if ( count( $params['tags'] ) ) {
+ if ( $params['tags'] ) {
$tagStatus = ChangeTags::canAddTagsAccompanyingChange( $params['tags'], $user );
if ( $tagStatus->isOK() ) {
$requestArray['wpChangeTags'] = implode( ',', $params['tags'] );
] );
// Check if user can add tags
- if ( count( $params['tags'] ) ) {
+ if ( $params['tags'] ) {
$ableToTag = ChangeTags::canAddTagsAccompanyingChange( $params['tags'], $this->getUser() );
if ( !$ableToTag->isOK() ) {
$this->dieStatus( $ableToTag );
}
$changes = [];
- if ( count( $params['change'] ) ) {
+ if ( $params['change'] ) {
foreach ( $params['change'] as $entry ) {
$array = explode( '=', $entry, 2 );
$changes[$array[0]] = isset( $array[1] ) ? $array[1] : null;
}
// Page protection filtering
- if ( count( $params['prtype'] ) || $params['prexpiry'] != 'all' ) {
+ if ( $params['prtype'] || $params['prexpiry'] != 'all' ) {
$this->addTables( 'page_restrictions' );
$this->addWhere( 'page_id=pr_page' );
$this->addWhere( "pr_expiry > {$db->addQuotes( $db->timestamp() )} OR pr_expiry IS NULL" );
- if ( count( $params['prtype'] ) ) {
+ if ( $params['prtype'] ) {
$this->addWhereFld( 'pr_type', $params['prtype'] );
if ( isset( $params['prlevel'] ) ) {
if ( count( $this->cont ) >= 2 ) {
$op = $this->params['dir'] == 'descending' ? '<' : '>';
- if ( count( $this->params['namespace'] ) > 1 ) {
+ if ( $this->params['namespace'] !== null && count( $this->params['namespace'] ) > 1 ) {
$this->addWhere(
"{$this->bl_from_ns} $op {$this->cont[0]} OR " .
"({$this->bl_from_ns} = {$this->cont[0]} AND " .
$this->addOption( 'LIMIT', $this->params['limit'] + 1 );
$sort = ( $this->params['dir'] == 'descending' ? ' DESC' : '' );
$orderBy = [];
- if ( count( $this->params['namespace'] ) > 1 ) {
+ if ( $this->params['namespace'] !== null && count( $this->params['namespace'] ) > 1 ) {
$orderBy[] = $this->bl_from_ns . $sort;
}
$orderBy[] = $this->bl_from . $sort;
$where = "{$this->bl_from} $op= {$this->cont[5]}";
// Don't bother with namespace, title, or from_namespace if it's
// otherwise constant in the where clause.
- if ( count( $this->params['namespace'] ) > 1 ) {
+ if ( $this->params['namespace'] !== null && count( $this->params['namespace'] ) > 1 ) {
$where = "{$this->bl_from_ns} $op {$this->cont[4]} OR " .
"({$this->bl_from_ns} = {$this->cont[4]} AND ($where))";
}
if ( count( $allRedirDBkey ) > 1 ) {
$orderBy[] = $this->bl_title . $sort;
}
- if ( count( $this->params['namespace'] ) > 1 ) {
+ if ( $this->params['namespace'] !== null && count( $this->params['namespace'] ) > 1 ) {
$orderBy[] = $this->bl_from_ns . $sort;
}
$orderBy[] = $this->bl_from . $sort;
}
} else {
$this->addWhereFld( "{$p}_from_namespace", $params['namespace'] );
- if ( !empty( $settings['from_namespace'] ) && count( $params['namespace'] ) > 1 ) {
+ if ( !empty( $settings['from_namespace'] )
+ && $params['namespace'] !== null && count( $params['namespace'] ) > 1
+ ) {
$sortby["{$p}_from_namespace"] = 'int';
}
}
* @param string|string[] $value Value; ignored if null or empty array;
*/
protected function addWhereFld( $field, $value ) {
- // Use count() to its full documented capabilities to simultaneously
- // test for null, empty array or empty countable object
- if ( count( $value ) ) {
+ if ( $value !== null && count( $value ) ) {
$this->where[$field] = $value;
}
}
// how to have efficient subcategory access :-) ~~~~ (oh well, domas)
$miser_ns = [];
if ( $this->getConfig()->get( 'MiserMode' ) ) {
- $miser_ns = $params['namespace'];
+ $miser_ns = $params['namespace'] ?: [];
} else {
$this->addWhereFld( 'page_namespace', $params['namespace'] );
}
$miser_ns = [];
if ( $this->getConfig()->get( 'MiserMode' ) ) {
- $miser_ns = $params['namespace'];
+ $miser_ns = $params['namespace'] ?: [];
} else {
$this->addWhereFld( 'page_namespace', $params['namespace'] );
}
}
} elseif ( $params['namespace'] ) {
$this->addWhereFld( $this->prefix . '_namespace', $params['namespace'] );
- $multiNS = count( $params['namespace'] ) !== 1;
+ $multiNS = $params['namespace'] === null || count( $params['namespace'] ) !== 1;
}
if ( !is_null( $params['continue'] ) ) {
}
// Check if user can add tags
- if ( count( $params['tags'] ) ) {
+ if ( $params['tags'] ) {
$ableToTag = ChangeTags::canAddTagsAccompanyingChange( $params['tags'], $user );
if ( !$ableToTag->isOK() ) {
$this->dieStatus( $ableToTag );
// If change tagging was requested, check that the user is allowed to tag,
// and the tags are valid
- if ( count( $params['tags'] ) ) {
+ if ( $params['tags'] ) {
$tagStatus = ChangeTags::canAddTagsAccompanyingChange( $params['tags'], $user );
if ( !$tagStatus->isOK() ) {
$this->dieStatus( $tagStatus );
// If change tagging was requested, check that the user is allowed to tag,
// and the tags are valid
- if ( count( $params['tags'] ) ) {
+ if ( $params['tags'] ) {
$tagStatus = ChangeTags::canAddTagsAccompanyingChange( $params['tags'], $user );
if ( !$tagStatus->isOK() ) {
$this->dieStatus( $tagStatus );
}
// Check if user can add tags
- if ( count( $params['tags'] ) ) {
+ if ( $params['tags'] ) {
$ableToTag = ChangeTags::canAddTagsAccompanyingChange( $params['tags'], $user );
if ( !$ableToTag->isOk() ) {
$this->dieStatus( $ableToTag );
} else {
$expiry = [ 'infinity' ];
}
- if ( count( $expiry ) !== count( $params['add'] ) ) {
+ $add = (array)$params['add'];
+ if ( 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
);