* @since 1.22
*/
public static function getBlocksForIPList( array $ipChain, $isAnon, $fromMaster = false ) {
- if ( !count( $ipChain ) ) {
+ if ( $ipChain === [] ) {
return [];
}
$conds[] = self::getRangeCond( IP::toHex( $ipaddr ) );
}
- if ( !count( $conds ) ) {
+ if ( $conds === [] ) {
return [];
}
* @return Block|null The "best" block from the list
*/
public static function chooseBlock( array $blocks, array $ipChain ) {
- if ( !count( $blocks ) ) {
+ if ( $blocks === [] ) {
return null;
} elseif ( count( $blocks ) == 1 ) {
return $blocks[0];
// Already compressed
return;
}
- if ( !count( $this->mItems ) ) {
- // Empty
+ if ( $this->mItems === [] ) {
return;
}
$this->mDiffs = [];
$this->mDiffMap = [];
foreach ( $sequences as $seq ) {
- if ( !count( $seq['diffs'] ) ) {
+ if ( $seq['diffs'] === [] ) {
continue;
}
if ( $tail === '' ) {
*/
function __sleep() {
$this->compress();
- if ( !count( $this->mItems ) ) {
- // Empty object
+ if ( $this->mItems === [] ) {
$info = false;
} else {
// Take forward differences to improve the compression ratio for sequences
}
// no group with the given right(s) exists, no need for a query
- if ( !count( $groups ) ) {
+ if ( $groups === [] ) {
$this->getResult()->addIndexedTagName( [ 'query', $this->getModuleName() ], '' );
return;
if ( count( $ids ) ) {
$ids = $this->filterIDs( [ [ $table, $field ] ], $ids );
- if ( !count( $ids ) ) {
+ if ( $ids === [] ) {
// Return nothing, no IDs are valid
$this->where[] = '0 = 1';
} else {
return $v >= $cont_page;
} );
}
- if ( !count( $pages ) ) {
+ if ( $pages === [] ) {
// Nothing to do
return;
}
$getTitles[] = $t->getTalkPage();
}
}
- if ( !count( $getTitles ) ) {
+ if ( $getTitles === [] ) {
return;
}
$pageIds = array_keys( $this->titles );
- if ( !count( $pageIds ) ) {
+ if ( $pageIds === [] ) {
return;
}
}
private function getVariantTitles() {
- if ( !count( $this->titles ) ) {
+ if ( $this->titles === [] ) {
return;
}
$this->variantTitles = [];
$pages = $filteredPages;
}
- if ( !count( $pages ) ) {
+ if ( $pages === [] ) {
# Nothing to do
return;
}
// prepareQuery might try to sort by actor and confuse everything.
$batchSize = 1;
} elseif ( isset( $this->params['userids'] ) ) {
- if ( !count( $this->params['userids'] ) ) {
+ if ( $this->params['userids'] === [] ) {
$encParamName = $this->encodeParamName( 'userids' );
$this->dieWithError( [ 'apierror-paramempty', $encParamName ], "paramempty_$encParamName" );
}
$writeSockets["$clientIndex/$i"] = $socket;
}
}
- if ( !count( $readSockets ) && !count( $writeSockets ) ) {
+ if ( $readSockets === [] && $writeSockets === [] ) {
break;
}
public function upsert( $table, array $rows, array $uniqueIndexes, array $set,
$fname = __METHOD__
) {
- if ( !count( $rows ) ) {
+ if ( $rows === [] ) {
return true; // nothing to do
}
* @return mixed[]
*/
public function mergeClassesIntoAttributes( array $classes, array $attribs ) {
- if ( !count( $classes ) ) {
+ if ( $classes === [] ) {
return $attribs;
}
* @return array[] An Array of arrays or iterators of file objects and the hash as key
*/
function findBySha1s( array $hashes ) {
- if ( !count( $hashes ) ) {
+ if ( $hashes === [] ) {
return []; // empty parameter
}
$conds['fa_sha1'] = $this->sha1;
}
- if ( !count( $conds ) ) {
+ if ( $conds === [] ) {
throw new MWException( "No specific information for retrieving archived file" );
}
final public function batchPush( array $jobs, $flags = 0 ) {
$this->assertNotReadOnly();
- if ( !count( $jobs ) ) {
+ if ( $jobs === [] ) {
return; // nothing to do
}
* @return void
*/
public function doBatchPushInternal( IDatabase $dbw, array $jobs, $flags, $method ) {
- if ( !count( $jobs ) ) {
+ if ( $jobs === [] ) {
return;
}
}
$jobs = is_array( $jobs ) ? $jobs : [ $jobs ];
- if ( !count( $jobs ) ) {
+ if ( $jobs === [] ) {
return;
}
}
}
- if ( !count( $items ) ) {
+ if ( $items === [] ) {
return; // nothing to do
}
if ( empty( $opts['bypassReadOnly'] ) && $this->isReadOnly() ) {
return $this->newStatus( 'backend-fail-readonly', $this->name, $this->readOnly );
}
- if ( !count( $ops ) ) {
+ if ( $ops === [] ) {
return $this->newStatus(); // nothing to do
}
if ( empty( $opts['bypassReadOnly'] ) && $this->isReadOnly() ) {
return $this->newStatus( 'backend-fail-readonly', $this->name, $this->readOnly );
}
- if ( !count( $ops ) ) {
+ if ( $ops === [] ) {
return $this->newStatus(); // nothing to do
}
* @return StatusValue
*/
final public function logChangeBatch( array $entries, $batchId ) {
- if ( !count( $entries ) ) {
+ if ( $entries === [] ) {
return StatusValue::newGood();
}
if ( $this->locksHeld[$path][$type] <= 0 ) {
unset( $this->locksHeld[$path][$type] );
}
- if ( !count( $this->locksHeld[$path] ) ) {
+ if ( $this->locksHeld[$path] === [] ) {
unset( $this->locksHeld[$path] ); // no locks on this path
if ( isset( $this->handles[$path] ) ) {
$handlesToClose[] = $this->handles[$path];
protected function doGetLocksOnServer( $lockSrv, array $paths, $type ) {
$status = StatusValue::newGood();
- if ( !count( $paths ) ) {
+ if ( $paths === [] ) {
return $status; // nothing to lock
}
$bucket = $this->getBucketFromPath( $path );
$pathsToUnlock[$bucket][$type][] = $path;
}
- if ( !count( $this->locksHeld[$path] ) ) {
+ if ( $this->locksHeld[$path] === [] ) {
unset( $this->locksHeld[$path] ); // no SH or EX locks left for key
}
}
foreach ( $pathsToUnlock as $bucket => $pathsToUnlockByType ) {
$status->merge( $this->doUnlockingRequestBucket( $bucket, $pathsToUnlockByType ) );
}
- if ( !count( $this->locksHeld ) ) {
+ if ( $this->locksHeld === [] ) {
$status->merge( $this->releaseAllLocks() );
$this->degradedBuckets = []; // safe to retry the normal quorum
}
);
}
- if ( !count( $this->shutdownPositions ) ) {
+ if ( $this->shutdownPositions === [] ) {
return []; // nothing to save
}
public function upsert( $table, array $rows, array $uniqueIndexes, array $set,
$fname = __METHOD__
) {
- if ( !count( $rows ) ) {
+ if ( $rows === [] ) {
return true; // nothing to do
}
public function upsert( $table, array $rows, array $uniqueIndexes,
array $set, $fname = __METHOD__
) {
- if ( !count( $rows ) ) {
+ if ( $rows === [] ) {
return true; // nothing to do
}
* @return array (reader index, lagged replica mode) or false on failure
*/
private function pickReaderIndex( array $loads, $domain = false ) {
- if ( !count( $loads ) ) {
+ if ( $loads === [] ) {
throw new InvalidArgumentException( "Empty server array given to LoadBalancer" );
}
}
// If all servers were down, quit now
- if ( !count( $currentLoads ) ) {
+ if ( $currentLoads === [] ) {
$this->connLogger->error( __METHOD__ . ": all servers down" );
}
// If nobody is watching the page, and there are no users notified on all changes
// don't bother creating a job/trying to send emails, unless it's a
// talk page with an applicable notification.
- if ( !count( $watchers ) && !count( $wgUsersNotifiedOnAllChanges ) ) {
+ if ( $watchers === [] && !count( $wgUsersNotifiedOnAllChanges ) ) {
$sendEmail = false;
// Only send notification for non minor edits, unless $wgEnotifMinorEdits
if ( !$minorEdit || ( $wgEnotifMinorEdits && !$editor->isAllowed( 'nominornewtalk' ) ) ) {
}
public function pop() {
- if ( !count( $this->stack ) ) {
+ if ( $this->stack === [] ) {
throw new MWException( __METHOD__ . ': no elements remaining' );
}
$temp = array_pop( $this->stack );
* @return array
*/
public function getFlags() {
- if ( !count( $this->stack ) ) {
+ if ( $this->stack === [] ) {
return [
'findEquals' => false,
'findPipe' => false,
}
// Save response to file cache unless there are errors
- if ( isset( $fileCache ) && !$this->errors && !count( $missing ) ) {
+ if ( isset( $fileCache ) && !$this->errors && $missing === [] ) {
// Cache single modules and images...and other requests if there are enough hits
if ( ResourceFileCache::useFileCache( $context ) ) {
if ( $fileCache->isCacheWorthy() ) {
$out = '';
$states = [];
- if ( !count( $modules ) && !count( $missing ) ) {
+ if ( $modules === [] && $missing === [] ) {
return <<<MESSAGE
/* This file is the Web entry point for MediaWiki's ResourceLoader:
<https://www.mediawiki.org/wiki/ResourceLoader>. In this request,
if ( is_null( $this->namespaces ) ) {
return '';
}
- if ( !count( $this->namespaces ) ) {
+ if ( $this->namespaces === [] ) {
$namespaces = '0';
} else {
$namespaces = $this->db->makeList( $this->namespaces );
if ( is_null( $this->namespaces ) ) {
return ''; # search all
}
- if ( !count( $this->namespaces ) ) {
+ if ( $this->namespaces === [] ) {
$namespaces = '0';
} else {
$namespaces = $this->db->makeList( $this->namespaces );
$out = $this->getOutput();
$allCats = $out->getCategoryLinks();
- if ( !count( $allCats ) ) {
+ if ( $allCats === [] ) {
return '';
}
* Attempts to clean up broken items
*/
private function cleanupWatchlist() {
- if ( !count( $this->badItems ) ) {
+ if ( $this->badItems === [] ) {
return; // nothing to do
}
'<span class="mw-listgrants-right-name">' . $permission . '</span>'
)->parse();
}
- if ( !count( $descs ) ) {
+ if ( $descs === [] ) {
$grantCellHtml = '';
} else {
sort( $descs );
'<span class="mw-passwordpolicies-policy-name">' . $gp . '</span>'
)->parse();
}
- if ( !count( $ret ) ) {
+ if ( $ret === [] ) {
return '';
} else {
return '<ul><li>' . implode( "</li>\n<li>", $ret ) . '</li></ul>';
$categories = array_map( 'trim', explode( '|', $opts['categories'] ) );
- if ( !count( $categories ) ) {
+ if ( $categories === [] ) {
return;
}
}
# Shortcut?
- if ( !count( $articles ) || !count( $cats ) ) {
+ if ( $articles === [] || $cats === [] ) {
return;
}
# Extract manually requested namespaces
$nslist = $this->powerSearch( $request );
- if ( !count( $nslist ) ) {
+ if ( $nslist === [] ) {
# Fallback to user preference
$nslist = $this->searchConfig->userNamespaces( $user );
}
$profile = null;
- if ( !count( $nslist ) ) {
+ if ( $nslist === [] ) {
$profile = 'default';
}
$pages = MediaWikiServices::getInstance()->getSpecialPageFactory()->
getUsablePages( $this->getUser() );
- if ( !count( $pages ) ) {
+ if ( $pages === [] ) {
# Yeah, that was pointless. Thanks for coming.
return false;
}
}
# Extra message, when no category was found
- if ( !count( $allMsgs ) ) {
+ if ( $allMsgs === [] ) {
$allMsgs[] = $this->msg( 'trackingcategories-disabled' )->parse();
}
if ( is_array( $data ) ) {
if ( isset( $data['user_groups'] ) && is_array( $data['user_groups'] ) ) {
- if ( !count( $data['user_groups'] ) ) {
+ if ( $data['user_groups'] === [] ) {
$this->mGroupMemberships = [];
} else {
$firstGroup = reset( $data['user_groups'] );
}
$toPromote = Autopromote::getAutopromoteOnceGroups( $this, $event );
- if ( !count( $toPromote ) ) {
+ if ( $toPromote === [] ) {
return [];
}