Also remove not necessary surrounding parentheses.
Change-Id: I0eb5c9c1bdfb09a800258379cdcefb5fd4d3d21c
$reason,
$context->getRequest()->getIP(),
$this->getByName(),
- $systemBlockType !== null ? $systemBlockType : $this->getId(),
+ $systemBlockType ?? $this->getId(),
$lang->formatExpiry( $this->mExpiry ),
(string)$intended,
$lang->userTimeAndDate( $this->mTimestamp, $context->getUser() ),
* @return string
*/
private function getKey( $methodKey = null ) {
- $key = $this->key !== null ? $this->key : $methodKey;
+ $key = $this->key ?? $methodKey;
if ( $key === null ) {
// @codeCoverageIgnoreStart
throw new InvalidArgumentException( '$key should not be null' );
}
$this->showTextbox(
- $textoverride !== null ? $textoverride : $this->textbox1,
+ $textoverride ?? $this->textbox1,
'wpTextbox1',
$attribs
);
if ( !property_exists( $row, 'old_flags' ) ) {
throw new InvalidArgumentException( 'old_flags was not set in $row' );
}
- $blobFlags = ( $row->old_flags === null ) ? '' : $row->old_flags;
+ $blobFlags = $row->old_flags ?? '';
}
$mainSlotRow->slot_revision_id = intval( $row->rev_id );
public function __construct( $canonicalServer, $path, $server = null ) {
$this->mCanonicalServer = $canonicalServer;
$this->mPath = $path;
- $this->mServer = $server === null ? $canonicalServer : $server;
+ $this->mServer = $server ?? $canonicalServer;
}
/**
$pageCounts = $this->pageCounts( $this->page );
- $pageProperties = [];
$props = PageProps::getInstance()->getAllProperties( $title );
- if ( isset( $props[$id] ) ) {
- $pageProperties = $props[$id];
- }
+ $pageProperties = $props[$id] ?? [];
// Basic information
$pageInfo = [];
$pageInfo['header-basic'] = [];
// Display title
- $displayTitle = $title->getPrefixedText();
- if ( isset( $pageProperties['displaytitle'] ) ) {
- $displayTitle = $pageProperties['displaytitle'];
- }
+ $displayTitle = $pageProperties['displaytitle'] ?? $title->getPrefixedText();
$pageInfo['header-basic'][] = [
$this->msg( 'pageinfo-display-title' ), $displayTitle
}
// Default sort key
- $sortKey = $title->getCategorySortkey();
- if ( isset( $pageProperties['defaultsort'] ) ) {
- $sortKey = $pageProperties['defaultsort'];
- }
+ $sortKey = $pageProperties['defaultsort'] ?? $title->getCategorySortkey();
$sortKey = htmlspecialchars( $sortKey );
$pageInfo['header-basic'][] = [ $this->msg( 'pageinfo-default-sort' ), $sortKey ];
$miser_ns = null;
if ( $mode == 'all' ) {
- if ( $params['namespace'] !== null ) {
- $namespaces = $params['namespace'];
- } else {
- $namespaces = MWNamespace::getValidNamespaces();
- }
+ $namespaces = $params['namespace'] ?? MWNamespace::getValidNamespaces();
$this->addWhereFld( 'ar_namespace', $namespaces );
// For from/to/prefix, we have to consider the potential
if ( !is_null( $params['continue'] ) ) {
$cont = explode( '|', $params['continue'] );
$this->dieContinueUsageIf( count( $cont ) != 1 );
- $op = ( $ascendingOrder ? '>' : '<' );
+ $op = $ascendingOrder ? '>' : '<';
$continueFrom = $db->addQuotes( $cont[0] );
$this->addWhere( "img_name $op= $continueFrom" );
}
// Image filters
- $from = ( $params['from'] === null ? null : $this->titlePartToKey( $params['from'], NS_FILE ) );
- $to = ( $params['to'] === null ? null : $this->titlePartToKey( $params['to'], NS_FILE ) );
- $this->addWhereRange( 'img_name', ( $ascendingOrder ? 'newer' : 'older' ), $from, $to );
+ $from = $params['from'] === null ? null : $this->titlePartToKey( $params['from'], NS_FILE );
+ $to = $params['to'] === null ? null : $this->titlePartToKey( $params['to'], NS_FILE );
+ $this->addWhereRange( 'img_name', $ascendingOrder ? 'newer' : 'older', $from, $to );
if ( isset( $params['prefix'] ) ) {
$this->addWhere( 'img_name' . $db->buildLike(
'ug_expiry IS NULL OR ug_expiry >= ' . $db->addQuotes( $db->timestamp() )
]
] ] );
- $groupCond = ( $params['filterbots'] == 'nobots' ? 'NULL' : 'NOT NULL' );
+ $groupCond = $params['filterbots'] == 'nobots' ? 'NULL' : 'NOT NULL';
$this->addWhere( "ug_group IS $groupCond" );
}
}
}
// 'continue' always overrides 'from'
- $from = ( $continue || $params['from'] === null ? null :
- $this->titlePartToKey( $params['from'], $namespace ) );
- $to = ( $params['to'] === null ? null :
- $this->titlePartToKey( $params['to'], $namespace ) );
+ $from = $continue || $params['from'] === null ? null :
+ $this->titlePartToKey( $params['from'], $namespace );
+ $to = $params['to'] === null ? null :
+ $this->titlePartToKey( $params['to'], $namespace );
$this->addWhereRange( $pfx . $fieldTitle, 'newer', $from, $to );
if ( isset( $params['prefix'] ) ) {
// some other module used up all the space. Just set a dummy
// continue and hope it works next time.
$this->setContinueEnumParameter( 'continue',
- $params['continue'] !== null ? $params['continue'] : '0|0'
+ $params['continue'] ?? '0|0'
);
return;
if ( count( $pageIds[NS_FILE] ) == 1 ) {
// See the 'the user is screwed' comment below
$this->setContinueEnumParameter( 'start',
- $start !== null ? $start : wfTimestamp( TS_ISO_8601, $img->getTimestamp() )
+ $start ?? wfTimestamp( TS_ISO_8601, $img->getTimestamp() )
);
} else {
$this->setContinueEnumParameter( 'continue',
// thing again. When the violating queries have been
// out-continued, the result will get through
$this->setContinueEnumParameter( 'start',
- $start !== null ? $start : wfTimestamp( TS_ISO_8601, $img->getTimestamp() )
+ $start ?? wfTimestamp( TS_ISO_8601, $img->getTimestamp() )
);
} else {
$this->setContinueEnumParameter( 'continue',
}
if ( LogEventsList::userCan( $row, LogPage::DELETED_USER, $user ) ) {
if ( $this->fld_user ) {
- $vals['user'] = $row->user_name === null ? $row->log_user_text : $row->user_name;
+ $vals['user'] = $row->user_name ?? $row->log_user_text;
}
if ( $this->fld_userid ) {
$vals['userid'] = intval( $row->log_user );
$this,
$titleObj,
$params['lang'],
- $params['reason'] === null ? '' : $params['reason'],
+ $params['reason'] ?? '',
$params['tags'] ?: []
);
$this->db = $db;
$this->tablesToClone = $tablesToClone;
$this->newTablePrefix = $newTablePrefix;
- $this->oldTablePrefix = $oldTablePrefix !== null ? $oldTablePrefix : $this->db->tablePrefix();
+ $this->oldTablePrefix = $oldTablePrefix ?? $this->db->tablePrefix();
$this->dropCurrentTables = $dropCurrentTables;
}
}
public function getDefault() {
- if ( isset( $this->mDefault ) ) {
- return $this->mDefault;
- } else {
- return null;
- }
+ return $this->mDefault ?? null;
}
/**
if ( FileBackend::isStoragePath( $path ) ) {
$res = FileBackend::normalizeStoragePath( $path );
- return ( $res !== null ) ? $res : $path;
+ return $res ?? $path;
}
return $path;
}
public function getTimestamp() {
- $ts = $this->timestamp !== null ? $this->timestamp : wfTimestampNow();
+ $ts = $this->timestamp ?? wfTimestampNow();
return wfTimestamp( TS_MW, $ts );
}
case 'LanguageCode':
$lang = Language::fetchLanguageName( strtolower( $val ), $this->getLanguage()->getCode() );
- if ( $lang ) {
- $val = htmlspecialchars( $lang );
- } else {
- $val = htmlspecialchars( $val );
- }
+ $val = htmlspecialchars( $lang ?: $val );
break;
default:
$it = $this->bcIterator();
$searchResult = $it->current();
$it->next();
- return $searchResult === null ? false : $searchResult;
+ return $searchResult ?? false;
}
/**
return;
}
$result->setExtensionData( function () use ( $id ) {
- if ( isset( $this->extraData[$id] ) ) {
- return $this->extraData[$id];
- } else {
- return [];
- }
+ return $this->extraData[$id] ?? [];
} );
}
'site_type' => $site->getType(),
'site_group' => $site->getGroup(),
'site_source' => $site->getSource(),
- 'site_language' => $site->getLanguageCode() === null ? '' : $site->getLanguageCode(),
+ 'site_language' => $site->getLanguageCode() ?? '',
'site_protocol' => $site->getProtocol(),
'site_domain' => strrev( $site->getDomain() ) . '.',
'site_data' => serialize( $site->getExtraData() ),
$batch = new LinkBatch;
foreach ( $res as $row ) {
- $batch->add( $ns !== null ? $ns : $row->namespace, $row->title );
+ $batch->add( $ns ?? $row->namespace, $row->title );
}
$batch->execute();
$this->opts = [];
$request = $this->getRequest();
- if ( $par !== null ) {
- $target = $par;
- } else {
- $target = $request->getVal( 'target' );
- }
+ $target = $par ?? $request->getVal( 'target' );
if ( $request->getVal( 'contribs' ) == 'newbie' || $par === 'newbies' ) {
$target = 'newbies';
$this->setHeaders();
$this->outputHeader();
- $this->filename = $par !== null ? $par : $this->getRequest()->getText( 'filename' );
+ $this->filename = $par ?? $this->getRequest()->getText( 'filename' );
$this->file = null;
$this->hash = '';
$title = Title::newFromText( $this->filename, NS_FILE );
$this->getContext(),
$title,
$newLanguage,
- $data['reason'] === null ? '' : $data['reason']
+ $data['reason'] ?? ''
);
}
return null;
}
- return $url === null ? $title->getFullUrlForRedirect() : $url;
+ return $url ?? $title->getFullUrlForRedirect();
}
/**
$out->addModules( [ 'mediawiki.special.userrights' ] );
- if ( $par !== null ) {
- $this->mTarget = $par;
- } else {
- $this->mTarget = $request->getVal( 'user' );
- }
+ $this->mTarget = $par ?? $request->getVal( 'user' );
if ( is_string( $this->mTarget ) ) {
$this->mTarget = trim( $this->mTarget );
$this->getUser()
) ) {
$value = CommentStore::getStore()->getComment( 'log_comment', $row )->text;
- $formatted = Linker::formatComment( $value !== null ? $value : '' );
+ $formatted = Linker::formatComment( $value ?? '' );
} else {
$formatted = $this->msg( 'rev-deleted-comment' )->escaped();
}
if ( $queryPage->isExpensive() ) {
$t1 = microtime( true );
# Do the query
- $num = $queryPage->recache( $limit === null ? $wgQueryCacheLimit : $limit );
+ $num = $queryPage->recache( $limit ?? $wgQueryCacheLimit );
$t2 = microtime( true );
if ( $num === false ) {
$this->output( "FAILED: database error\n" );
}
public function shouldEmbedModule( ResourceLoaderContext $context ) {
- return $this->shouldEmbed !== null ? $this->shouldEmbed : parent::shouldEmbedModule( $context );
+ return $this->shouldEmbed ?? parent::shouldEmbedModule( $context );
}
public function enableModuleContentVersion() {
$comment = CommentStoreComment::newUnsavedComment( $summary );
if ( !$content instanceof Content ) {
- $content = new WikitextContent( $content === null ? $summary : $content );
+ $content = new WikitextContent( $content ?? $summary );
}
$this->getDerivedPageDataUpdater( $page ); // flush cached instance before.
$comment = CommentStoreComment::newUnsavedComment( $summary );
if ( !$content instanceof Content ) {
- $content = new TextContent( $content === null ? $summary : $content );
+ $content = new TextContent( $content ?? $summary );
}
$updater = $page->newPageUpdater( $user );
$normalExpiry = $config->get( 'CookieExpiration' );
$extendedExpiry = $config->get( 'ExtendedLoginCookieExpiration' );
- $extendedExpiry = (int)( $extendedExpiry === null ? 0 : $extendedExpiry );
+ $extendedExpiry = (int)( $extendedExpiry ?? 0 );
$expect = [
'MySessionName' => [
'value' => (string)$sessionId,