Use the null coalescing assignment operator
Available since PHP 7.4. Automated search, manual replacement. Change-Id: Ibb163141526e799bff08cfeb4037b52144bb39fa
This commit is contained in:
parent
d2b199c517
commit
43a93d9782
53 changed files with 74 additions and 75 deletions
|
|
@ -1654,7 +1654,7 @@ class Linker {
|
|||
* @return string Full html of the TOC
|
||||
*/
|
||||
public static function tocList( $toc, Language $lang = null ) {
|
||||
$lang = $lang ?? RequestContext::getMain()->getLanguage();
|
||||
$lang ??= RequestContext::getMain()->getLanguage();
|
||||
|
||||
$title = wfMessage( 'toc' )->inLanguage( $lang )->escaped();
|
||||
|
||||
|
|
|
|||
|
|
@ -257,7 +257,7 @@ class ClientHtml {
|
|||
// Change "client-nojs" class to client-js. This allows easy toggling of UI components.
|
||||
// This must happen synchronously on every page view to avoid flashes of wrong content.
|
||||
// See also startup/startup.js.
|
||||
$nojsClass = $nojsClass ?? $this->getDocumentAttributes()['class'];
|
||||
$nojsClass ??= $this->getDocumentAttributes()['class'];
|
||||
$jsClass = preg_replace( '/(^|\s)client-nojs(\s|$)/', '$1client-js$2', $nojsClass );
|
||||
$jsClassJson = $this->context->encodeJson( $jsClass );
|
||||
$script = "
|
||||
|
|
|
|||
|
|
@ -76,7 +76,7 @@ class ResponseFactory {
|
|||
* @return Response
|
||||
*/
|
||||
public function createJson( $value, $contentType = null ) {
|
||||
$contentType = $contentType ?? self::CT_JSON;
|
||||
$contentType ??= self::CT_JSON;
|
||||
$response = new Response( $this->encodeJson( $value ) );
|
||||
$response->setHeader( 'Content-Type', $contentType );
|
||||
return $response;
|
||||
|
|
|
|||
|
|
@ -1013,7 +1013,7 @@ return [
|
|||
|
||||
$wanParams['cache'] = $store;
|
||||
$wanParams['logger'] = $logger;
|
||||
$wanParams['secret'] = $wanParams['secret'] ?? $mainConfig->get( MainConfigNames::SecretKey );
|
||||
$wanParams['secret'] ??= $mainConfig->get( MainConfigNames::SecretKey );
|
||||
if ( !$GLOBALS[ 'wgCommandLineMode' ] ) {
|
||||
// Send the statsd data post-send on HTTP requests; avoid in CLI mode (T181385)
|
||||
$wanParams['stats'] = $services->getStatsdDataFactory();
|
||||
|
|
|
|||
|
|
@ -129,7 +129,7 @@ if ( !interface_exists( LoggerInterface::class ) ) {
|
|||
}
|
||||
|
||||
// Set $wgCommandLineMode to false if it wasn't set to true.
|
||||
$wgCommandLineMode = $wgCommandLineMode ?? false;
|
||||
$wgCommandLineMode ??= false;
|
||||
|
||||
/**
|
||||
* $wgConf hold the site configuration.
|
||||
|
|
@ -138,7 +138,7 @@ $wgCommandLineMode = $wgCommandLineMode ?? false;
|
|||
*/
|
||||
$wgConf = new SiteConfiguration;
|
||||
|
||||
$wgAutoloadClasses = $wgAutoloadClasses ?? [];
|
||||
$wgAutoloadClasses ??= [];
|
||||
|
||||
$wgSettings = new SettingsBuilder(
|
||||
MW_INSTALL_PATH,
|
||||
|
|
|
|||
|
|
@ -115,7 +115,7 @@ class ExternalStoreAccess implements LoggerAwareInterface {
|
|||
* @throws ExternalStoreException
|
||||
*/
|
||||
public function insert( $data, array $params = [], array $tryStores = null ) {
|
||||
$tryStores = $tryStores ?? $this->storeFactory->getWriteBaseUrls();
|
||||
$tryStores ??= $this->storeFactory->getWriteBaseUrls();
|
||||
if ( !$tryStores ) {
|
||||
throw new ExternalStoreException( "List of external stores provided is empty." );
|
||||
}
|
||||
|
|
|
|||
|
|
@ -161,9 +161,8 @@ class FileBackendGroup {
|
|||
}
|
||||
$class = $config['class'];
|
||||
|
||||
$config['domainId'] =
|
||||
$config['domainId'] ?? $config['wikiId'] ?? $this->options->get( 'fallbackWikiId' );
|
||||
$config['readOnly'] = $config['readOnly'] ?? $readOnlyReason;
|
||||
$config['domainId'] ??= $config['wikiId'] ?? $this->options->get( 'fallbackWikiId' );
|
||||
$config['readOnly'] ??= $readOnlyReason;
|
||||
|
||||
unset( $config['class'] ); // backend won't need this
|
||||
$this->backends[$name] = [
|
||||
|
|
|
|||
|
|
@ -2231,7 +2231,7 @@ abstract class File implements IDBAccessObject, MediaHandlerState {
|
|||
return false;
|
||||
}
|
||||
|
||||
$lang = $lang ?? $wgLang;
|
||||
$lang ??= $wgLang;
|
||||
|
||||
$renderUrl = $this->repo->getDescriptionRenderUrl( $this->getName(), $lang->getCode() );
|
||||
if ( $renderUrl ) {
|
||||
|
|
|
|||
|
|
@ -96,7 +96,7 @@ class ForeignDBFile extends LocalFile {
|
|||
return false;
|
||||
}
|
||||
|
||||
$lang = $lang ?? $wgLang;
|
||||
$lang ??= $wgLang;
|
||||
$renderUrl = $this->repo->getDescriptionRenderUrl( $this->getName(), $lang->getCode() );
|
||||
if ( !$renderUrl ) {
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ class HTMLTimezoneField extends HTMLSelectOrOtherField {
|
|||
if ( isset( $params['options'] ) ) {
|
||||
throw new InvalidArgumentException( "Options should not be provided to " . __CLASS__ );
|
||||
}
|
||||
$params['placeholder-message'] = $params['placeholder-message'] ?? 'timezone-useoffset-placeholder';
|
||||
$params['placeholder-message'] ??= 'timezone-useoffset-placeholder';
|
||||
$params['options'] = [];
|
||||
parent::__construct( $params );
|
||||
$lang = $this->mParent ? $this->mParent->getLanguage() : RequestContext::getMain()->getLanguage();
|
||||
|
|
|
|||
|
|
@ -74,7 +74,7 @@ class LimitBatch {
|
|||
}
|
||||
|
||||
private function queueOp( $type, $entity, $amount ) {
|
||||
$amount = $amount ?? $this->defaultAmount;
|
||||
$amount ??= $this->defaultAmount;
|
||||
if ( isset( $this->operations[$type] ) ) {
|
||||
throw new WRStatsError( __METHOD__ .
|
||||
': cannot queue multiple actions of the same type, ' .
|
||||
|
|
|
|||
|
|
@ -79,7 +79,7 @@ class WRStatsReader {
|
|||
if ( $metricSpec === null ) {
|
||||
throw new WRStatsError( __METHOD__ . ": Unrecognised metric \"$metricName\"" );
|
||||
}
|
||||
$entity = $entity ?? new LocalEntityKey;
|
||||
$entity ??= new LocalEntityKey;
|
||||
$now = $this->now();
|
||||
$seqSpec = null;
|
||||
foreach ( $metricSpec->sequences as $seqSpec ) {
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ class WRStatsWriter {
|
|||
*/
|
||||
public function incr( $name, ?EntityKey $entity = null, $value = 1 ) {
|
||||
$metricSpec = $this->metricSpecs[$name] ?? null;
|
||||
$entity = $entity ?? new LocalEntityKey;
|
||||
$entity ??= new LocalEntityKey;
|
||||
if ( $metricSpec === null ) {
|
||||
throw new WRStatsError( __METHOD__ . ": Unrecognised metric \"$name\"" );
|
||||
}
|
||||
|
|
@ -128,7 +128,7 @@ class WRStatsWriter {
|
|||
* components. The default is the empty local entity.
|
||||
*/
|
||||
public function resetAll( ?array $entities = null ) {
|
||||
$entities = $entities ?? [ new LocalEntityKey ];
|
||||
$entities ??= [ new LocalEntityKey ];
|
||||
$this->queuedValues = [];
|
||||
$keys = [];
|
||||
foreach ( $this->metricSpecs as $name => $metricSpec ) {
|
||||
|
|
|
|||
|
|
@ -751,7 +751,7 @@ abstract class FileBackendStore extends FileBackend {
|
|||
foreach ( $stats as $path => $stat ) {
|
||||
if ( is_array( $stat ) ) {
|
||||
// Strongly consistent backends might automatically set this flag
|
||||
$stat['latest'] = $stat['latest'] ?? $latest;
|
||||
$stat['latest'] ??= $latest;
|
||||
|
||||
$this->cheapCache->setField( $path, 'stat', $stat );
|
||||
if ( isset( $stat['sha1'] ) ) {
|
||||
|
|
@ -1049,8 +1049,8 @@ abstract class FileBackendStore extends FileBackend {
|
|||
$status = $this->newStatus();
|
||||
|
||||
// Always set some fields for subclass convenience
|
||||
$params['options'] = $params['options'] ?? [];
|
||||
$params['headers'] = $params['headers'] ?? [];
|
||||
$params['options'] ??= [];
|
||||
$params['headers'] ??= [];
|
||||
|
||||
// Don't stream it out as text/html if there was a PHP error
|
||||
if ( ( empty( $params['headless'] ) || $params['headers'] ) && headers_sent() ) {
|
||||
|
|
|
|||
|
|
@ -283,8 +283,8 @@ class SwiftFileBackend extends FileBackendStore {
|
|||
// Headers that are not strictly a function of the file content
|
||||
$mutableHeaders = $this->extractMutableContentHeaders( $params['headers'] ?? [] );
|
||||
// Make sure that the "content-type" header is set to something sensible
|
||||
$mutableHeaders['content-type'] = $mutableHeaders['content-type']
|
||||
?? $this->getContentType( $params['dst'], $params['content'], null );
|
||||
$mutableHeaders['content-type']
|
||||
??= $this->getContentType( $params['dst'], $params['content'], null );
|
||||
|
||||
$reqs = [ [
|
||||
'method' => 'PUT',
|
||||
|
|
@ -370,8 +370,8 @@ class SwiftFileBackend extends FileBackendStore {
|
|||
// Headers that are not strictly a function of the file content
|
||||
$mutableHeaders = $this->extractMutableContentHeaders( $params['headers'] ?? [] );
|
||||
// Make sure that the "content-type" header is set to something sensible
|
||||
$mutableHeaders['content-type'] = $mutableHeaders['content-type']
|
||||
?? $this->getContentType( $params['dst'], null, $params['src'] );
|
||||
$mutableHeaders['content-type']
|
||||
??= $this->getContentType( $params['dst'], null, $params['src'] );
|
||||
|
||||
$reqs = [ [
|
||||
'method' => 'PUT',
|
||||
|
|
@ -1374,7 +1374,7 @@ class SwiftFileBackend extends FileBackendStore {
|
|||
foreach ( $reqs as $stage => &$req ) {
|
||||
list( $container, $relPath ) = $req['url'];
|
||||
$req['url'] = $this->storageUrl( $auth, $container, $relPath );
|
||||
$req['headers'] = $req['headers'] ?? [];
|
||||
$req['headers'] ??= [];
|
||||
$req['headers'] = $this->authTokenHeaders( $auth ) + $req['headers'];
|
||||
$httpReqsByStage[$stage][$index] = $req;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -655,7 +655,7 @@ class MultiHttpClient implements LoggerAwareInterface {
|
|||
if ( $this->localProxy !== false && $this->isLocalURL( $req['url'] ) ) {
|
||||
$this->useReverseProxy( $req, $this->localProxy );
|
||||
}
|
||||
$req['query'] = $req['query'] ?? [];
|
||||
$req['query'] ??= [];
|
||||
$headers = []; // normalized headers
|
||||
if ( isset( $req['headers'] ) ) {
|
||||
foreach ( $req['headers'] as $name => $value ) {
|
||||
|
|
@ -681,7 +681,7 @@ class MultiHttpClient implements LoggerAwareInterface {
|
|||
'headers' => $logHeaders,
|
||||
]
|
||||
);
|
||||
$req['flags'] = $req['flags'] ?? [];
|
||||
$req['flags'] ??= [];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ class HashBagOStuff extends MediumSpecificBagOStuff {
|
|||
* @phan-param array{logger?:Psr\Log\LoggerInterface,asyncHandler?:callable,keyspace?:string,reportDupes?:bool,segmentationSize?:int,segmentedValueMaxSize?:int,maxKeys?:int} $params
|
||||
*/
|
||||
public function __construct( $params = [] ) {
|
||||
$params['segmentationSize'] = $params['segmentationSize'] ?? INF;
|
||||
$params['segmentationSize'] ??= INF;
|
||||
parent::__construct( $params );
|
||||
|
||||
$this->token = microtime( true ) . ':' . mt_rand();
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ abstract class MemcachedBagOStuff extends MediumSpecificBagOStuff {
|
|||
* unprefixed access. This can be used with mcrouter. [optional]
|
||||
*/
|
||||
public function __construct( array $params ) {
|
||||
$params['segmentationSize'] = $params['segmentationSize'] ?? 917504; // < 1MiB
|
||||
$params['segmentationSize'] ??= 917504; // < 1MiB
|
||||
parent::__construct( $params );
|
||||
|
||||
$this->routingPrefix = $params['routingPrefix'] ?? '';
|
||||
|
|
|
|||
|
|
@ -130,7 +130,7 @@ class RESTBagOStuff extends MediumSpecificBagOStuff {
|
|||
private $extendedErrorBodyFields;
|
||||
|
||||
public function __construct( $params ) {
|
||||
$params['segmentationSize'] = $params['segmentationSize'] ?? INF;
|
||||
$params['segmentationSize'] ??= INF;
|
||||
if ( empty( $params['url'] ) ) {
|
||||
throw new InvalidArgumentException( 'URL parameter is required' );
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@
|
|||
*/
|
||||
class WinCacheBagOStuff extends MediumSpecificBagOStuff {
|
||||
public function __construct( array $params = [] ) {
|
||||
$params['segmentationSize'] = $params['segmentationSize'] ?? INF;
|
||||
$params['segmentationSize'] ??= INF;
|
||||
parent::__construct( $params );
|
||||
|
||||
if ( PHP_SAPI === 'cli' ) {
|
||||
|
|
|
|||
|
|
@ -74,7 +74,7 @@ class ConnectionManager {
|
|||
* @return IDatabase
|
||||
*/
|
||||
private function getConnection( $i, ?array $groups = null, int $flags = 0 ) {
|
||||
$groups = $groups ?? $this->groups;
|
||||
$groups ??= $this->groups;
|
||||
return $this->loadBalancer->getConnection( $i, $groups, $this->domain, $flags );
|
||||
}
|
||||
|
||||
|
|
@ -84,7 +84,7 @@ class ConnectionManager {
|
|||
* @return DBConnRef
|
||||
*/
|
||||
private function getConnectionRef( $i, array $groups = null ) {
|
||||
$groups = $groups ?? $this->groups;
|
||||
$groups ??= $this->groups;
|
||||
return $this->loadBalancer->getConnectionRef( $i, $groups, $this->domain );
|
||||
}
|
||||
|
||||
|
|
@ -110,7 +110,7 @@ class ConnectionManager {
|
|||
* @return IDatabase
|
||||
*/
|
||||
public function getReadConnection( ?array $groups = null, int $flags = 0 ) {
|
||||
$groups = $groups ?? $this->groups;
|
||||
$groups ??= $this->groups;
|
||||
return $this->getConnection( DB_REPLICA, $groups, $flags );
|
||||
}
|
||||
|
||||
|
|
@ -144,7 +144,7 @@ class ConnectionManager {
|
|||
* @deprecated since 1.38; Use getReadConnection()
|
||||
*/
|
||||
public function getReadConnectionRef( array $groups = null ) {
|
||||
$groups = $groups ?? $this->groups;
|
||||
$groups ??= $this->groups;
|
||||
return $this->getConnectionRef( DB_REPLICA, $groups );
|
||||
}
|
||||
|
||||
|
|
@ -168,7 +168,7 @@ class ConnectionManager {
|
|||
* @deprecated since 1.39; Use getReadConnection()
|
||||
*/
|
||||
public function getLazyReadConnectionRef( array $groups = null ) {
|
||||
$groups = $groups ?? $this->groups;
|
||||
$groups ??= $this->groups;
|
||||
return $this->getConnectionRef( DB_REPLICA, $groups );
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -262,7 +262,7 @@ class TransactionManager {
|
|||
* @param Throwable $sessionError
|
||||
*/
|
||||
public function setSessionError( Throwable $sessionError ) {
|
||||
$this->sessionError = $this->sessionError ?? $sessionError;
|
||||
$this->sessionError ??= $sessionError;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -1939,7 +1939,7 @@ class LoadBalancer implements ILoadBalancerForOwner {
|
|||
}
|
||||
|
||||
public function hasOrMadeRecentPrimaryChanges( $age = null ) {
|
||||
$age = $age ?? $this->waitTimeout;
|
||||
$age ??= $this->waitTimeout;
|
||||
|
||||
return ( $this->hasPrimaryChanges()
|
||||
|| $this->lastPrimaryChangeTimestamp() > microtime( true ) - $age );
|
||||
|
|
|
|||
|
|
@ -164,7 +164,7 @@ class ObjectCache {
|
|||
}
|
||||
|
||||
$class = $params['class'];
|
||||
$conf = $conf ?? $services->getMainConfig();
|
||||
$conf ??= $services->getMainConfig();
|
||||
|
||||
// Do config normalization for SqlBagOStuff
|
||||
if ( is_a( $class, SqlBagOStuff::class, true ) ) {
|
||||
|
|
|
|||
|
|
@ -2121,7 +2121,7 @@ class WikiPage implements Page, IDBAccessObject, PageRecord {
|
|||
* @since 1.32
|
||||
*/
|
||||
public function doSecondaryDataUpdates( array $options = [] ) {
|
||||
$options['recursive'] = $options['recursive'] ?? true;
|
||||
$options['recursive'] ??= true;
|
||||
$revision = $this->getRevisionRecord();
|
||||
if ( !$revision || !$revision->getId() ) {
|
||||
LoggerFactory::getInstance( 'wikipage' )->info(
|
||||
|
|
@ -2759,7 +2759,7 @@ class WikiPage implements Page, IDBAccessObject, PageRecord {
|
|||
throw new InvalidArgumentException( 'Mismatching page ID' );
|
||||
}
|
||||
|
||||
$user = $user ?? new UserIdentityValue( 0, 'unknown' );
|
||||
$user ??= new UserIdentityValue( 0, 'unknown' );
|
||||
$services = MediaWikiServices::getInstance();
|
||||
$deletePage = $services->getDeletePageFactory()->newDeletePage(
|
||||
$this,
|
||||
|
|
|
|||
|
|
@ -165,7 +165,7 @@ class DateFormatter {
|
|||
* @return DateFormatter
|
||||
*/
|
||||
public static function getInstance( Language $lang = null ) {
|
||||
$lang = $lang ?? MediaWikiServices::getInstance()->getContentLanguage();
|
||||
$lang ??= MediaWikiServices::getInstance()->getContentLanguage();
|
||||
return MediaWikiServices::getInstance()->getDateFormatterFactory()->get( $lang );
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -286,7 +286,7 @@ class ParserCache {
|
|||
ParserOptions $options,
|
||||
array $usedOptions = null
|
||||
): string {
|
||||
$usedOptions = $usedOptions ?? ParserOptions::allCacheVaryingOptions();
|
||||
$usedOptions ??= ParserOptions::allCacheVaryingOptions();
|
||||
// idhash seem to mean 'page id' + 'rendering hash' (r3710)
|
||||
$pageid = $page->getId( PageRecord::LOCAL );
|
||||
$title = $this->titleFactory->castFromPageIdentity( $page );
|
||||
|
|
|
|||
|
|
@ -1441,7 +1441,7 @@ class ParserOptions {
|
|||
public function isSafeToCache( array $usedOptions = null ) {
|
||||
$defaults = self::getDefaults();
|
||||
$inCacheKey = self::getCacheVaryingOptionsHash();
|
||||
$usedOptions = $usedOptions ?? array_keys( $this->options );
|
||||
$usedOptions ??= array_keys( $this->options );
|
||||
foreach ( $usedOptions as $option ) {
|
||||
if ( empty( $inCacheKey[$option] ) && empty( self::$callbacks[$option] ) ) {
|
||||
$v = $this->optionToString( $this->options[$option] ?? null );
|
||||
|
|
|
|||
|
|
@ -246,7 +246,7 @@ LUA;
|
|||
'@phan-var RedisConnRef $conn';
|
||||
|
||||
$now = microtime( true );
|
||||
$timeout = $timeout ?? $this->timeout;
|
||||
$timeout ??= $this->timeout;
|
||||
try {
|
||||
$slot = $this->initAndPopPoolSlotList( $conn, $now );
|
||||
if ( ctype_digit( $slot ) ) {
|
||||
|
|
|
|||
|
|
@ -90,7 +90,7 @@ class MultiTitleFilter implements Filter {
|
|||
* @return PageStore
|
||||
*/
|
||||
private function getPageStore(): PageStore {
|
||||
$this->pageStore = $this->pageStore ?? MediaWikiServices::getInstance()->getPageStore();
|
||||
$this->pageStore ??= MediaWikiServices::getInstance()->getPageStore();
|
||||
return $this->pageStore;
|
||||
}
|
||||
|
||||
|
|
@ -98,7 +98,7 @@ class MultiTitleFilter implements Filter {
|
|||
* @return TitleFormatter
|
||||
*/
|
||||
private function getTitleFormatter(): TitleFormatter {
|
||||
$this->titleFormatter = $this->titleFormatter ?? MediaWikiServices::getInstance()->getTitleFormatter();
|
||||
$this->titleFormatter ??= MediaWikiServices::getInstance()->getTitleFormatter();
|
||||
return $this->titleFormatter;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -83,7 +83,7 @@ class MultiUsernameFilter implements Filter {
|
|||
* @return CentralIdLookup
|
||||
*/
|
||||
private function getLookup() {
|
||||
$this->lookup = $this->lookup ?? MediaWikiServices::getInstance()->getCentralIdLookup();
|
||||
$this->lookup ??= MediaWikiServices::getInstance()->getCentralIdLookup();
|
||||
return $this->lookup;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@ class SearchResultThumbnailProvider {
|
|||
* @return SearchResultThumbnail|null
|
||||
*/
|
||||
public function buildSearchResultThumbnailFromFile( File $file, int $size = null ): ?SearchResultThumbnail {
|
||||
$size = $size ?? self::THUMBNAIL_SIZE;
|
||||
$size ??= self::THUMBNAIL_SIZE;
|
||||
|
||||
$thumb = $file->transform( [ 'width' => $size , 'height' => $size ] );
|
||||
if ( !$thumb || $thumb->isError() ) {
|
||||
|
|
|
|||
|
|
@ -537,8 +537,8 @@ class SpecialContributions extends IncludableSpecialPage {
|
|||
HookRunner $hookRunner = null
|
||||
) {
|
||||
// Fallback to global state, if not provided
|
||||
$permissionManager = $permissionManager ?? MediaWikiServices::getInstance()->getPermissionManager();
|
||||
$hookRunner = $hookRunner ?? Hooks::runner();
|
||||
$permissionManager ??= MediaWikiServices::getInstance()->getPermissionManager();
|
||||
$hookRunner ??= Hooks::runner();
|
||||
|
||||
$id = $target->getId();
|
||||
$username = $target->getName();
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ class SpecialGoToInterwiki extends UnlistedSpecialPage {
|
|||
}
|
||||
|
||||
public function execute( $par ) {
|
||||
$par = $par ?? '';
|
||||
$par ??= '';
|
||||
|
||||
// Allow forcing an interstitial for local interwikis. This is used
|
||||
// when a redirect page is reached via a special page which resolves
|
||||
|
|
|
|||
|
|
@ -225,7 +225,7 @@ class SpecialLog extends SpecialPage {
|
|||
*/
|
||||
private function parseParams( FormOptions $opts, $par ) {
|
||||
# Get parameters
|
||||
$par = $par ?? '';
|
||||
$par ??= '';
|
||||
$parms = explode( '/', $par );
|
||||
$symsForAll = [ '*', 'all' ];
|
||||
if ( $parms[0] != '' &&
|
||||
|
|
|
|||
|
|
@ -229,7 +229,7 @@ class SpecialPageLanguage extends FormSpecialPage {
|
|||
}
|
||||
|
||||
// Load the page language from DB
|
||||
$dbw = $dbw ?? wfGetDB( DB_PRIMARY );
|
||||
$dbw ??= wfGetDB( DB_PRIMARY );
|
||||
$oldLanguage = $dbw->selectField(
|
||||
'page',
|
||||
'page_lang',
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ class SpecialRandomPage extends SpecialPage {
|
|||
$this->loadBalancer = $loadBalancer instanceof ILoadBalancer
|
||||
? $loadBalancer
|
||||
: $services->getDBLoadBalancer();
|
||||
$nsInfo = $nsInfo ?? $services->getNamespaceInfo();
|
||||
$nsInfo ??= $services->getNamespaceInfo();
|
||||
$this->namespaces = $nsInfo->getContentNamespaces();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ class SpecialUpload extends SpecialPage {
|
|||
parent::__construct( 'Upload', 'upload' );
|
||||
// This class is extended and therefor fallback to global state - T265300
|
||||
$services = MediaWikiServices::getInstance();
|
||||
$repoGroup = $repoGroup ?? $services->getRepoGroup();
|
||||
$repoGroup ??= $services->getRepoGroup();
|
||||
$this->localRepo = $repoGroup->getLocalRepo();
|
||||
$this->userOptionsLookup = $userOptionsLookup ?? $services->getUserOptionsLookup();
|
||||
$this->nsInfo = $nsInfo ?? $services->getNamespaceInfo();
|
||||
|
|
|
|||
|
|
@ -170,7 +170,7 @@ class AllMessagesTablePager extends TablePager {
|
|||
) {
|
||||
// FIXME: This function should be moved to Language:: or something.
|
||||
// Fallback to global state, if not provided
|
||||
$dbr = $dbr ?? wfGetDB( DB_REPLICA );
|
||||
$dbr ??= wfGetDB( DB_REPLICA );
|
||||
$res = $dbr->select( 'page',
|
||||
[ 'page_namespace', 'page_title' ],
|
||||
[ 'page_namespace' => [ NS_MEDIAWIKI, NS_MEDIAWIKI_TALK ] ],
|
||||
|
|
|
|||
|
|
@ -169,7 +169,7 @@ class ContribsPager extends RangeChronologicalPager {
|
|||
) {
|
||||
// Class is used directly in extensions - T266484
|
||||
$services = MediaWikiServices::getInstance();
|
||||
$loadBalancer = $loadBalancer ?? $services->getDBLoadBalancer();
|
||||
$loadBalancer ??= $services->getDBLoadBalancer();
|
||||
|
||||
// Set ->target before calling parent::__construct() so
|
||||
// parent can call $this->getIndexField() and get the right result. Set
|
||||
|
|
|
|||
|
|
@ -95,7 +95,7 @@ class UsersPager extends AlphabeticPager {
|
|||
$this->setContext( $context );
|
||||
|
||||
$request = $this->getRequest();
|
||||
$par = $par ?? '';
|
||||
$par ??= '';
|
||||
$parms = explode( '/', $par );
|
||||
$symsForAll = [ '*', 'user' ];
|
||||
|
||||
|
|
|
|||
|
|
@ -146,7 +146,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 ?? '';
|
||||
$name ??= '';
|
||||
if ( $actorId === null ) {
|
||||
throw new InvalidArgumentException( "Actor ID is null for {$name} and {$userId}" );
|
||||
}
|
||||
|
|
|
|||
|
|
@ -102,7 +102,7 @@ class CentralIdLookupFactory {
|
|||
* @throws InvalidArgumentException if $providerId is not properly configured
|
||||
*/
|
||||
public function getLookup( string $providerId = null ): CentralIdLookup {
|
||||
$providerId = $providerId ?? $this->defaultProvider;
|
||||
$providerId ??= $this->defaultProvider;
|
||||
|
||||
if ( !array_key_exists( $providerId, $this->instanceCache ) ) {
|
||||
$providerSpec = $this->providers[$providerId] ?? null;
|
||||
|
|
|
|||
|
|
@ -206,8 +206,8 @@ class PasswordReset implements LoggerAwareInterface {
|
|||
return StatusValue::newFatal( 'badipaddress' );
|
||||
}
|
||||
|
||||
$username = $username ?? '';
|
||||
$email = $email ?? '';
|
||||
$username ??= '';
|
||||
$email ??= '';
|
||||
|
||||
$resetRoutes = $this->config->get( MainConfigNames::PasswordResetRoutes )
|
||||
+ [ 'username' => false, 'email' => false ];
|
||||
|
|
|
|||
|
|
@ -1709,7 +1709,7 @@ abstract class MediaWikiIntegrationTestCase extends PHPUnit\Framework\TestCase {
|
|||
|
||||
self::$oldTablePrefix = $wgDBprefix;
|
||||
|
||||
$testPrefix = $testPrefix ?? self::getTestPrefixFor( $db );
|
||||
$testPrefix ??= self::getTestPrefixFor( $db );
|
||||
|
||||
// switch to a temporary clone of the database
|
||||
self::$useTemporaryTables = $useTemporaryTables ?? self::$useTemporaryTables;
|
||||
|
|
@ -2606,7 +2606,7 @@ abstract class MediaWikiIntegrationTestCase extends PHPUnit\Framework\TestCase {
|
|||
* @param Authority|null $deleter
|
||||
*/
|
||||
protected function deletePage( ProperPageIdentity $page, string $summary = '', Authority $deleter = null ): void {
|
||||
$deleter = $deleter ?? new UltimateAuthority( new UserIdentityValue( 0, 'MediaWiki default' ) );
|
||||
$deleter ??= new UltimateAuthority( new UserIdentityValue( 0, 'MediaWiki default' ) );
|
||||
MediaWikiServices::getInstance()->getDeletePageFactory()
|
||||
->newDeletePage( $page, $deleter )
|
||||
->deleteUnsafe( $summary );
|
||||
|
|
|
|||
|
|
@ -677,7 +677,7 @@ hello
|
|||
|
||||
$elmosEdit['wpSummary'] = 'Elmo\'s edit';
|
||||
$bertasEdit['wpSummary'] = 'Bertas\'s edit';
|
||||
$newEdit['wpSummary'] = $newEdit['wpSummary'] ?? 'new edit';
|
||||
$newEdit['wpSummary'] ??= 'new edit';
|
||||
|
||||
// first edit: Elmo
|
||||
$page = $this->assertEdit( __METHOD__, null, 'Elmo', $elmosEdit,
|
||||
|
|
|
|||
|
|
@ -1927,7 +1927,7 @@ class TitleTest extends MediaWikiIntegrationTestCase {
|
|||
|
||||
$this->setService( 'RestrictionStore', $mockRestrictionStore );
|
||||
|
||||
$options['expectedReturn'] = $options['expectedReturn'] ?? $return;
|
||||
$options['expectedReturn'] ??= $return;
|
||||
|
||||
$comparisonMethod = isset( $options['weakCompareReturn'] ) ? 'assertEquals' : 'assertSame';
|
||||
|
||||
|
|
|
|||
|
|
@ -80,7 +80,7 @@ class ActionTest extends MediaWikiIntegrationTestCase {
|
|||
WikiPage $wikiPage = null,
|
||||
IContextSource $context = null
|
||||
): Article {
|
||||
$context = $context ?? $this->getContext();
|
||||
$context ??= $this->getContext();
|
||||
if ( $wikiPage !== null ) {
|
||||
$context->setWikiPage( $wikiPage );
|
||||
$context->setTitle( $wikiPage->getTitle() );
|
||||
|
|
|
|||
|
|
@ -104,7 +104,7 @@ class WikiPageDbTest extends MediaWikiLangTestCase {
|
|||
$page = $this->newPage( $page, $model );
|
||||
}
|
||||
|
||||
$performer = $performer ?? $this->getTestUser()->getUser();
|
||||
$performer ??= $this->getTestUser()->getUser();
|
||||
|
||||
if ( is_string( $content ) ) {
|
||||
$content = ContentHandler::makeContent( $content, $page->getTitle(), $model );
|
||||
|
|
|
|||
|
|
@ -89,7 +89,7 @@ class BlockListPagerTest extends MediaWikiIntegrationTestCase {
|
|||
MWTimestamp::setFakeTime( MWTimestamp::time() );
|
||||
|
||||
$value = $name === 'ipb_timestamp' ? MWTimestamp::time() : '';
|
||||
$expected = $expected ?? MWTimestamp::getInstance()->format( 'H:i, j F Y' );
|
||||
$expected ??= MWTimestamp::getInstance()->format( 'H:i, j F Y' );
|
||||
|
||||
$row = $row ?: (object)[];
|
||||
$pager = $this->getBlockListPager();
|
||||
|
|
|
|||
|
|
@ -915,7 +915,7 @@ class ParsoidHandlerTest extends MediaWikiIntegrationTestCase {
|
|||
|
||||
$attribs += self::DEFAULT_ATTRIBS;
|
||||
$attribs['opts'] += self::DEFAULT_ATTRIBS['opts'];
|
||||
$attribs['opts']['from'] = $attribs['opts']['from'] ?? 'html';
|
||||
$attribs['opts']['from'] ??= 'html';
|
||||
$attribs['envOptions'] += self::DEFAULT_ATTRIBS['envOptions'];
|
||||
|
||||
if ( $attribs['oldid'] ) {
|
||||
|
|
@ -945,7 +945,7 @@ class ParsoidHandlerTest extends MediaWikiIntegrationTestCase {
|
|||
|
||||
$attribs = self::DEFAULT_ATTRIBS;
|
||||
$attribs['opts'] += self::DEFAULT_ATTRIBS['opts'];
|
||||
$attribs['opts']['from'] = $attribs['opts']['from'] ?? 'html';
|
||||
$attribs['opts']['from'] ??= 'html';
|
||||
$attribs['envOptions'] += self::DEFAULT_ATTRIBS['envOptions'];
|
||||
|
||||
$metrics = new class () extends MockMetrics {
|
||||
|
|
@ -1269,7 +1269,7 @@ class ParsoidHandlerTest extends MediaWikiIntegrationTestCase {
|
|||
|
||||
$attribs += self::DEFAULT_ATTRIBS;
|
||||
$attribs['opts'] += self::DEFAULT_ATTRIBS['opts'];
|
||||
$attribs['opts']['from'] = $attribs['opts']['from'] ?? 'html';
|
||||
$attribs['opts']['from'] ??= 'html';
|
||||
$attribs['envOptions'] += self::DEFAULT_ATTRIBS['envOptions'];
|
||||
|
||||
$handler = $this->newParsoidHandler();
|
||||
|
|
|
|||
|
|
@ -80,7 +80,7 @@ class SearchHandlerTest extends \MediaWikiUnitTestCase {
|
|||
|
||||
/** @var Language|MockObject $language */
|
||||
$language = $this->createNoOpMock( Language::class );
|
||||
$hookContainer = $hookContainer ?? $this->createHookContainer();
|
||||
$hookContainer ??= $this->createHookContainer();
|
||||
/** @var UserOptionsLookup|MockObject $userOptionsLookup */
|
||||
$userOptionsLookup = $this->createMock( UserOptionsLookup::class );
|
||||
$searchEngineConfig = new \SearchEngineConfig(
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ class LanguageNameUtilsTest extends MediaWikiUnitTestCase {
|
|||
*/
|
||||
private function newObj( array $optionsArray = [] ): LanguageNameUtils {
|
||||
// TODO Why is hookContainer unset here sometimes?
|
||||
$this->hookContainer = $this->hookContainer ?? $this->createHookContainer();
|
||||
$this->hookContainer ??= $this->createHookContainer();
|
||||
return new LanguageNameUtils(
|
||||
new ServiceOptions(
|
||||
LanguageNameUtils::CONSTRUCTOR_OPTIONS,
|
||||
|
|
|
|||
Loading…
Reference in a new issue