Merge "Use null coalecing operators everywhere consistenctly."
This commit is contained in:
commit
96c6af6878
13 changed files with 18 additions and 25 deletions
|
|
@ -1985,7 +1985,7 @@ class EditPage implements IEditObject {
|
|||
$constraintRunner->addConstraint(
|
||||
$constraintFactory->newSpamRegexConstraint(
|
||||
$this->summary,
|
||||
$this->section === null ? '' : $this->section,
|
||||
$this->section ?? '',
|
||||
$this->sectiontitle,
|
||||
$this->textbox1,
|
||||
$this->context->getRequest()->getIP(),
|
||||
|
|
|
|||
|
|
@ -226,7 +226,7 @@ HTML;
|
|||
* Output headers that prevents error pages to be cached.
|
||||
*/
|
||||
function outputHTMLHeader() {
|
||||
$protocol = isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0';
|
||||
$protocol = $_SERVER['SERVER_PROTOCOL'] ?? 'HTTP/1.0';
|
||||
|
||||
header( "$protocol 500 MediaWiki configuration Error" );
|
||||
// Don't cache error pages! They cause no end of trouble...
|
||||
|
|
|
|||
|
|
@ -466,9 +466,7 @@ class RevisionStore
|
|||
|
||||
$pageId = $this->failOnEmpty( $rev->getPageId( $this->wikiId ), 'rev_page field' ); // check this early
|
||||
|
||||
$parentId = $rev->getParentId() === null
|
||||
? $this->getPreviousRevisionId( $dbw, $rev )
|
||||
: $rev->getParentId();
|
||||
$parentId = $rev->getParentId() ?? $this->getPreviousRevisionId( $dbw, $rev );
|
||||
|
||||
/** @var RevisionRecord $rev */
|
||||
$rev = $dbw->doAtomicSection(
|
||||
|
|
@ -2388,7 +2386,7 @@ class RevisionStore
|
|||
// Could not initialize the user, maybe it doesn't exist?
|
||||
if ( isset( $fields['user_text'] ) ) {
|
||||
$user = new UserIdentityValue(
|
||||
$userID === null ? 0 : $userID,
|
||||
$userID ?? 0,
|
||||
$fields['user_text'],
|
||||
$this->wikiId
|
||||
);
|
||||
|
|
|
|||
|
|
@ -172,11 +172,11 @@ class SiteStatsInit {
|
|||
*/
|
||||
public function refresh() {
|
||||
$set = [
|
||||
'ss_total_edits' => $this->edits === null ? $this->edits() : $this->edits,
|
||||
'ss_good_articles' => $this->articles === null ? $this->articles() : $this->articles,
|
||||
'ss_total_pages' => $this->pages === null ? $this->pages() : $this->pages,
|
||||
'ss_users' => $this->users === null ? $this->users() : $this->users,
|
||||
'ss_images' => $this->files === null ? $this->files() : $this->files,
|
||||
'ss_total_edits' => $this->edits ?? $this->edits(),
|
||||
'ss_good_articles' => $this->articles ?? $this->articles(),
|
||||
'ss_total_pages' => $this->pages ?? $this->pages(),
|
||||
'ss_users' => $this->users ?? $this->users(),
|
||||
'ss_images' => $this->files ?? $this->files(),
|
||||
];
|
||||
$row = [ 'ss_row_id' => 1 ] + $set;
|
||||
|
||||
|
|
|
|||
|
|
@ -442,7 +442,7 @@ class ApiQueryWatchlist extends ApiQueryGeneratorBase {
|
|||
if ( $this->fld_expiry ) {
|
||||
// Add expiration, T263796
|
||||
$expiry = $watchedItem->getExpiry( TS_ISO_8601 );
|
||||
$vals['expiry'] = ( $expiry === null ? false : $expiry );
|
||||
$vals['expiry'] = ( $expiry ?? false );
|
||||
}
|
||||
|
||||
if ( $anyHidden && ( $recentChangeInfo['rc_deleted'] & RevisionRecord::DELETED_RESTRICTED ) ) {
|
||||
|
|
|
|||
|
|
@ -4975,9 +4975,7 @@ abstract class Database implements IDatabase, IMaintainableDatabase, LoggerAware
|
|||
}
|
||||
|
||||
public function affectedRows() {
|
||||
return ( $this->affectedRowCount === null )
|
||||
? $this->fetchAffectedRowCount() // default to driver value
|
||||
: $this->affectedRowCount;
|
||||
return $this->affectedRowCount ?? $this->fetchAffectedRowCount();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -2090,7 +2090,7 @@ class LoadBalancer implements ILoadBalancer {
|
|||
}
|
||||
|
||||
public function hasOrMadeRecentMasterChanges( $age = null ) {
|
||||
$age = ( $age === null ) ? $this->waitTimeout : $age;
|
||||
$age = $age ?? $this->waitTimeout;
|
||||
|
||||
return ( $this->hasMasterChanges()
|
||||
|| $this->lastMasterChangeTimestamp() > microtime( true ) - $age );
|
||||
|
|
|
|||
|
|
@ -170,7 +170,7 @@ final class UserInfo {
|
|||
* @return User
|
||||
*/
|
||||
public function getUser() {
|
||||
return $this->user === null ? new User : $this->user;
|
||||
return $this->user ?? new User;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -614,7 +614,7 @@ class Site implements Serializable {
|
|||
*/
|
||||
public function getPath( $pathType ) {
|
||||
$paths = $this->getAllPaths();
|
||||
return array_key_exists( $pathType, $paths ) ? $paths[$pathType] : null;
|
||||
return $paths[$pathType] ?? null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -833,8 +833,7 @@ class SpecialBlock extends FormSpecialPage {
|
|||
|
||||
// Reason, to be passed to the block object. For default values of reason, see
|
||||
// HTMLSelectAndOtherField::getDefault
|
||||
// @phan-suppress-next-line PhanPluginDuplicateConditionalNullCoalescing
|
||||
$blockReason = isset( $data['Reason'][0] ) ? $data['Reason'][0] : '';
|
||||
$blockReason = $data['Reason'][0] ?? '';
|
||||
|
||||
$pageRestrictions = [];
|
||||
$namespaceRestrictions = [];
|
||||
|
|
|
|||
|
|
@ -147,7 +147,7 @@ class ActorStore implements UserIdentityLookup, ActorNormalization {
|
|||
// from ActorMigration aliases to proper join with the actor table,
|
||||
// we should use ::newActorFromRow more, and eventually deprecate this method.
|
||||
$userId = $userId === null ? 0 : (int)$userId;
|
||||
$name = $name === null ? '' : $name;
|
||||
$name = $name ?? '';
|
||||
if ( $actorId === null ) {
|
||||
throw new InvalidArgumentException( "Actor ID is null for {$name} and {$userId}" );
|
||||
}
|
||||
|
|
|
|||
|
|
@ -306,7 +306,7 @@ class User implements Authority, IDBAccessObject, UserIdentity, UserEmailContact
|
|||
if ( $name === 'mRights' ) {
|
||||
MediaWikiServices::getInstance()->getPermissionManager()->overrideUserRightsForTesting(
|
||||
$this,
|
||||
$value === null ? [] : $value
|
||||
$value ?? []
|
||||
);
|
||||
} elseif ( $name === 'mOptions' ) {
|
||||
wfDeprecated( 'User::$mOptions', '1.35' );
|
||||
|
|
|
|||
|
|
@ -542,9 +542,7 @@ class WatchlistManager {
|
|||
$changingWatchStatus = (bool)$oldWatchedItem !== $watch;
|
||||
if ( $oldWatchedItem && $expiry !== null ) {
|
||||
// If there's an old watched item, a non-null change to the expiry requires an UPDATE.
|
||||
$oldWatchPeriod = $oldWatchedItem->getExpiry() === null
|
||||
? 'infinity'
|
||||
: $oldWatchedItem->getExpiry();
|
||||
$oldWatchPeriod = $oldWatchedItem->getExpiry() ?? 'infinity';
|
||||
$changingWatchStatus = $changingWatchStatus ||
|
||||
$oldWatchPeriod !== ExpiryDef::normalizeExpiry( $expiry, TS_MW );
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue