switch ( $this->mode ) {
case 'get':
- $this->func_name = isset( $_GET["rs"] ) ? $_GET["rs"] : '';
+ $this->func_name = $_GET["rs"] ?? '';
if ( !empty( $_GET["rsargs"] ) ) {
$this->args = $_GET["rsargs"];
} else {
}
break;
case 'post':
- $this->func_name = isset( $_POST["rs"] ) ? $_POST["rs"] : '';
+ $this->func_name = $_POST["rs"] ?? '';
if ( !empty( $_POST["rsargs"] ) ) {
$this->args = $_POST["rsargs"];
} else {
protected function initFromRow( $row ) {
$this->setTarget( $row->ipb_address );
$this->setBlocker( User::newFromAnyId(
- $row->ipb_by, $row->ipb_by_text, isset( $row->ipb_by_actor ) ? $row->ipb_by_actor : null
+ $row->ipb_by, $row->ipb_by_text, $row->ipb_by_actor ?? null
) );
$this->mTimestamp = wfTimestamp( TS_MW, $row->ipb_timestamp );
private function getCommentInternal( IDatabase $db = null, $key, $row, $fallback = false ) {
$row = (array)$row;
if ( array_key_exists( "{$key}_text", $row ) && array_key_exists( "{$key}_data", $row ) ) {
- $cid = isset( $row["{$key}_cid"] ) ? $row["{$key}_cid"] : null;
+ $cid = $row["{$key}_cid"] ?? null;
$text = $row["{$key}_text"];
$data = $row["{$key}_data"];
} elseif ( $this->stage === MIGRATION_OLD ) {
$query = $query . '&' . $extraQueryRedirect;
}
}
- $anchor = isset( $resultDetails['sectionanchor'] ) ? $resultDetails['sectionanchor'] : '';
+ $anchor = $resultDetails['sectionanchor'] ?? '';
$out->redirect( $this->mTitle->getFullURL( $query ) . $anchor );
return false;
$checkboxesDef = $this->getCheckboxesDefinition( $checked );
foreach ( $checkboxesDef as $name => $options ) {
- $legacyName = isset( $options['legacy-name'] ) ? $options['legacy-name'] : $name;
+ $legacyName = $options['legacy-name'] ?? $name;
$title = null;
$accesskey = null;
'align' => 'inline',
'label' => new OOUI\HtmlSnippet( $this->context->msg( $options['label-message'] )->parse() ),
'title' => $title,
- 'id' => isset( $options['label-id'] ) ? $options['label-id'] : null,
+ 'id' => $options['label-id'] ?? null,
]
);
}
$prefix = $wgCookiePrefix;
}
$name = $prefix . $key;
- return isset( $this->cookies[$name] ) ? $this->cookies[$name] : $default;
+ return $this->cookies[$name] ?? $default;
}
/**
$frames = array_map( function ( $frame ) use ( $frameFormat ) {
$file = !empty( $frame['file'] ) ? basename( $frame['file'] ) : '-';
- $line = isset( $frame['line'] ) ? $frame['line'] : '-';
+ $line = $frame['line'] ?? '-';
$call = $frame['function'];
if ( !empty( $frame['class'] ) ) {
$call = $frame['class'] . $frame['type'] . $call;
}
$includeStderr = isset( $options['duplicateStderr'] ) && $options['duplicateStderr'];
- $profileMethod = isset( $options['profileMethod'] ) ? $options['profileMethod'] : wfGetCaller();
+ $profileMethod = $options['profileMethod'] ?? wfGetCaller();
try {
$result = Shell::command( [] )
unset( $attribs['type'] );
}
if ( $element === 'input' ) {
- $type = isset( $attribs['type'] ) ? $attribs['type'] : null;
- $value = isset( $attribs['value'] ) ? $attribs['value'] : null;
+ $type = $attribs['type'] ?? null;
+ $value = $attribs['value'] ?? null;
if ( $type === 'checkbox' || $type === 'radio' ) {
// The default value for checkboxes and radio buttons is 'on'
// not ''. By stripping value="" we break radio boxes that
if ( isset( $params['label'] ) ) {
$ret .= self::element(
'label', [
- 'for' => isset( $selectAttribs['id'] ) ? $selectAttribs['id'] : null,
+ 'for' => $selectAttribs['id'] ?? null,
], $params['label']
) . ' ';
}
}
// Clean up parameters
- $page = isset( $handlerParams['page'] ) ? $handlerParams['page'] : false;
+ $page = $handlerParams['page'] ?? false;
if ( !isset( $frameParams['align'] ) ) {
$frameParams['align'] = '';
}
$params = [
'alt' => $frameParams['alt'],
'title' => $frameParams['title'],
- 'valign' => isset( $frameParams['valign'] ) ? $frameParams['valign'] : false,
+ 'valign' => $frameParams['valign'] ?? false,
'img-class' => $frameParams['class'] ];
if ( isset( $frameParams['border'] ) ) {
$params['img-class'] .= ( $params['img-class'] !== '' ? ' ' : '' ) . 'thumbborder';
) {
$exists = $file && $file->exists();
- $page = isset( $handlerParams['page'] ) ? $handlerParams['page'] : false;
+ $page = $handlerParams['page'] ?? false;
if ( !isset( $frameParams['align'] ) ) {
$frameParams['align'] = 'right';
}
*/
public static function getNamespaceContentModel( $index ) {
global $wgNamespaceContentModels;
- return isset( $wgNamespaceContentModels[$index] )
- ? $wgNamespaceContentModels[$index]
- : null;
+ return $wgNamespaceContentModels[$index] ?? null;
}
/**
try {
$statsdServer = explode( ':', $config->get( 'StatsdServer' ) );
$statsdHost = $statsdServer[0];
- $statsdPort = isset( $statsdServer[1] ) ? $statsdServer[1] : 8125;
+ $statsdPort = $statsdServer[1] ?? 8125;
$statsdSender = new SocketSender( $statsdHost, $statsdPort );
$statsdClient = new SamplingStatsdClient( $statsdSender, true, false );
$statsdClient->setSamplingRates( $config->get( 'StatsdSamplingRates' ) );
echo $templateParser->processTemplate(
'NoLocalSettings',
[
- 'wgVersion' => ( isset( $wgVersion ) ? $wgVersion : 'VERSION' ),
+ 'wgVersion' => ( $wgVersion ?? 'VERSION' ),
'path' => $path,
'localSettingsExists' => file_exists( MW_CONFIG_FILE ),
'installerStarted' => $installerStarted
// Register a callback for $this->contentOverrides on the first call
$this->addContentOverrideCallback( function ( LinkTarget $target ) {
$key = $target->getNamespace() . ':' . $target->getDBkey();
- return isset( $this->contentOverrides[$key] )
- ? $this->contentOverrides[$key]
- : null;
+ return $this->contentOverrides[$key] ?? null;
} );
}
if ( $type == ResourceLoaderModule::TYPE_COMBINED ) {
return min( array_values( $this->mAllowedModules ) );
} else {
- return isset( $this->mAllowedModules[$type] )
- ? $this->mAllowedModules[$type]
- : ResourceLoaderModule::ORIGIN_ALL;
+ return $this->mAllowedModules[$type] ?? ResourceLoaderModule::ORIGIN_ALL;
}
}
*/
public static function setupOOUI( $skinName = 'default', $dir = 'ltr' ) {
$themes = ResourceLoaderOOUIModule::getSkinThemeMap();
- $theme = isset( $themes[$skinName] ) ? $themes[$skinName] : $themes['default'];
+ $theme = $themes[$skinName] ?? $themes['default'];
// For example, 'OOUI\WikimediaUITheme'.
$themeClass = "OOUI\\{$theme}Theme";
OOUI\Theme::setSingleton( new $themeClass() );
$searchParts = explode( '/', $search, 2 );
$searchKey = $searchParts[0];
- $subpageSearch = isset( $searchParts[1] ) ? $searchParts[1] : null;
+ $subpageSearch = $searchParts[1] ?? null;
// Handle subpage search separately.
if ( $subpageSearch !== null ) {
return $row['title'];
}
- $pageId = isset( $row['page'] ) ? $row['page'] : 0;
- $revId = isset( $row['id'] ) ? $row['id'] : 0;
+ $pageId = $row['page'] ?? 0;
+ $revId = $row['id'] ?? 0;
} else {
- $pageId = isset( $row->rev_page ) ? $row->rev_page : 0;
- $revId = isset( $row->rev_id ) ? $row->rev_id : 0;
+ $pageId = $row->rev_page ?? 0;
+ $revId = $row->rev_id ?? 0;
}
try {
foreach ( $config['paths'] as $prefix => $serviceConfig ) {
$class = $serviceConfig['class'];
// Merge in the global defaults
- $constructArg = isset( $serviceConfig['options'] )
- ? $serviceConfig['options']
- : [];
+ $constructArg = $serviceConfig['options'] ?? [];
$constructArg += $config['global'];
// Make the VRS service available at the mount point
$vrsClient->mount( $prefix, [ 'class' => $class, 'config' => $constructArg ] );
try {
$user = User::newFromAnyId(
- isset( $row->ar_user ) ? $row->ar_user : null,
- isset( $row->ar_user_text ) ? $row->ar_user_text : null,
- isset( $row->ar_actor ) ? $row->ar_actor : null
+ $row->ar_user ?? null,
+ $row->ar_user_text ?? null,
+ $row->ar_actor ?? null
);
} catch ( InvalidArgumentException $ex ) {
wfWarn( __METHOD__ . ': ' . $ex->getMessage() );
Assert::parameterType( 'object', $row, '$row' );
if ( !$title ) {
- $pageId = isset( $row->rev_page ) ? $row->rev_page : 0; // XXX: also check page_id?
- $revId = isset( $row->rev_id ) ? $row->rev_id : 0;
+ $pageId = $row->rev_page ?? 0; // XXX: also check page_id?
+ $revId = $row->rev_id ?? 0;
$title = $this->getTitle( $pageId, $revId, $queryFlags );
}
try {
$user = User::newFromAnyId(
- isset( $row->rev_user ) ? $row->rev_user : null,
- isset( $row->rev_user_text ) ? $row->rev_user_text : null,
- isset( $row->rev_actor ) ? $row->rev_actor : null
+ $row->rev_user ?? null,
+ $row->rev_user_text ?? null,
+ $row->rev_actor ?? null
);
} catch ( InvalidArgumentException $ex ) {
wfWarn( __METHOD__ . ': ' . $ex->getMessage() );
}
if ( !$title ) {
- $pageId = isset( $fields['page'] ) ? $fields['page'] : 0;
- $revId = isset( $fields['id'] ) ? $fields['id'] : 0;
+ $pageId = $fields['page'] ?? 0;
+ $revId = $fields['id'] ?? 0;
$title = $this->getTitle( $pageId, $revId, $queryFlags );
}
isset( $fields['comment'] )
&& !( $fields['comment'] instanceof CommentStoreComment )
) {
- $commentData = isset( $fields['comment_data'] ) ? $fields['comment_data'] : null;
+ $commentData = $fields['comment_data'] ?? null;
if ( $fields['comment'] instanceof Message ) {
$fields['comment'] = CommentStoreComment::newUnsavedComment(
} else {
try {
$user = User::newFromAnyId(
- isset( $fields['user'] ) ? $fields['user'] : null,
- isset( $fields['user_text'] ) ? $fields['user_text'] : null,
- isset( $fields['actor'] ) ? $fields['actor'] : null
+ $fields['user'] ?? null,
+ $fields['user_text'] ?? null,
+ $fields['actor'] ?? null
);
} catch ( InvalidArgumentException $ex ) {
$user = null;
if ( !$this->mRestrictionsLoaded ) {
$this->loadRestrictions();
}
- return isset( $this->mRestrictions[$action] )
- ? $this->mRestrictions[$action]
- : [];
+ return $this->mRestrictions[$action] ?? [];
}
/**
if ( !$this->mRestrictionsLoaded ) {
$this->loadRestrictions();
}
- return isset( $this->mRestrictionsExpiry[$action] ) ? $this->mRestrictionsExpiry[$action] : false;
+ return $this->mRestrictionsExpiry[$action] ?? false;
}
/**
$a = parse_url( $url );
Wikimedia\restoreWarnings();
if ( $a ) {
- $path = isset( $a['path'] ) ? $a['path'] : '';
+ $path = $a['path'] ?? '';
global $wgScript;
if ( $path == $wgScript && $want !== 'all' ) {
// This method is called from various error handlers and should be kept simple.
if ( !self::$reqId ) {
- self::$reqId = isset( $_SERVER['UNIQUE_ID'] )
- ? $_SERVER['UNIQUE_ID'] : wfRandomString( 24 );
+ self::$reqId = $_SERVER['UNIQUE_ID'] ?? wfRandomString( 24 );
}
return self::$reqId;
* @return mixed Old value if one was present, null otherwise
*/
public function setVal( $key, $value ) {
- $ret = isset( $this->data[$key] ) ? $this->data[$key] : null;
+ $ret = $this->data[$key] ?? null;
$this->data[$key] = $value;
return $ret;
}
* @return string
*/
public function getMethod() {
- return isset( $_SERVER['REQUEST_METHOD'] ) ? $_SERVER['REQUEST_METHOD'] : 'GET';
+ return $_SERVER['REQUEST_METHOD'] ?? 'GET';
}
/**
$path .= '?' . $urlParts['query'];
}
- $canonicalServer = isset( $urlParts['scheme'] ) ? $urlParts['scheme'] : 'http';
+ $canonicalServer = $urlParts['scheme'] ?? 'http';
$canonicalServer .= '://' . $urlParts['host'];
return new WikiReference( $canonicalServer, $path );
# Sometimes rev_len isn't populated
if ( $rev->getSize() !== null ) {
# Size is always public data
- $prevSize = isset( $this->parentLens[$row->rev_parent_id] )
- ? $this->parentLens[$row->rev_parent_id]
- : 0;
+ $prevSize = $this->parentLens[$row->rev_parent_id] ?? 0;
$sDiff = ChangesList::showCharacterDifference( $prevSize, $rev->getSize() );
$fSize = Linker::formatRevisionSize( $rev->getSize() );
$s .= ' <span class="mw-changeslist-separator">. .</span> ' . "$fSize $sDiff";
$this->module = $module;
$params = $module->extractRequestParams();
- $this->messageFormat = isset( $params['messageformat'] ) ? $params['messageformat'] : 'wikitext';
+ $this->messageFormat = $params['messageformat'] ?? 'wikitext';
}
/**
];
}
- $default = isset( $paramSettings[self::PARAM_DFLT] )
- ? $paramSettings[self::PARAM_DFLT]
- : null;
- $multi = isset( $paramSettings[self::PARAM_ISMULTI] )
- ? $paramSettings[self::PARAM_ISMULTI]
- : false;
- $multiLimit1 = isset( $paramSettings[self::PARAM_ISMULTI_LIMIT1] )
- ? $paramSettings[self::PARAM_ISMULTI_LIMIT1]
- : null;
- $multiLimit2 = isset( $paramSettings[self::PARAM_ISMULTI_LIMIT2] )
- ? $paramSettings[self::PARAM_ISMULTI_LIMIT2]
- : null;
- $type = isset( $paramSettings[self::PARAM_TYPE] )
- ? $paramSettings[self::PARAM_TYPE]
- : null;
- $dupes = isset( $paramSettings[self::PARAM_ALLOW_DUPLICATES] )
- ? $paramSettings[self::PARAM_ALLOW_DUPLICATES]
- : false;
- $deprecated = isset( $paramSettings[self::PARAM_DEPRECATED] )
- ? $paramSettings[self::PARAM_DEPRECATED]
- : false;
- $deprecatedValues = isset( $paramSettings[self::PARAM_DEPRECATED_VALUES] )
- ? $paramSettings[self::PARAM_DEPRECATED_VALUES]
- : [];
- $required = isset( $paramSettings[self::PARAM_REQUIRED] )
- ? $paramSettings[self::PARAM_REQUIRED]
- : false;
- $allowAll = isset( $paramSettings[self::PARAM_ALL] )
- ? $paramSettings[self::PARAM_ALL]
- : false;
+ $default = $paramSettings[self::PARAM_DFLT] ?? null;
+ $multi = $paramSettings[self::PARAM_ISMULTI] ?? false;
+ $multiLimit1 = $paramSettings[self::PARAM_ISMULTI_LIMIT1] ?? null;
+ $multiLimit2 = $paramSettings[self::PARAM_ISMULTI_LIMIT2] ?? null;
+ $type = $paramSettings[self::PARAM_TYPE] ?? null;
+ $dupes = $paramSettings[self::PARAM_ALLOW_DUPLICATES] ?? false;
+ $deprecated = $paramSettings[self::PARAM_DEPRECATED] ?? false;
+ $deprecatedValues = $paramSettings[self::PARAM_DEPRECATED_VALUES] ?? [];
+ $required = $paramSettings[self::PARAM_REQUIRED] ?? false;
+ $allowAll = $paramSettings[self::PARAM_ALL] ?? false;
// When type is not given, and no choices, the type is the same as $default
if ( !isset( $type ) ) {
}
break;
case 'integer': // Force everything using intval() and optionally validate limits
- $min = isset( $paramSettings[self::PARAM_MIN] ) ? $paramSettings[self::PARAM_MIN] : null;
- $max = isset( $paramSettings[self::PARAM_MAX] ) ? $paramSettings[self::PARAM_MAX] : null;
- $enforceLimits = isset( $paramSettings[self::PARAM_RANGE_ENFORCE] )
- ? $paramSettings[self::PARAM_RANGE_ENFORCE] : false;
+ $min = $paramSettings[self::PARAM_MIN] ?? null;
+ $max = $paramSettings[self::PARAM_MAX] ?? null;
+ $enforceLimits = $paramSettings[self::PARAM_RANGE_ENFORCE] ?? false;
if ( is_array( $value ) ) {
$value = array_map( 'intval', $value );
if ( $multi ) {
self::dieDebug( __METHOD__, "Multi-values not supported for $encParamName" );
}
- $min = isset( $paramSettings[self::PARAM_MIN] ) ? $paramSettings[self::PARAM_MIN] : 0;
+ $min = $paramSettings[self::PARAM_MIN] ?? 0;
if ( $value == 'max' ) {
$value = $this->getMain()->canApiHighLimits()
? $paramSettings[self::PARAM_MAX2]
'api-help-param-token',
$this->needsToken(),
],
- ] + ( isset( $params['token'] ) ? $params['token'] : [] );
+ ] + ( $params['token'] ?? [] );
}
// Avoid PHP 7.1 warning of passing $this by reference
$settings = [];
}
- $d = isset( $desc[$param] ) ? $desc[$param] : '';
+ $d = $desc[$param] ?? '';
if ( is_array( $d ) ) {
// Special handling for prop parameters
$d = array_map( function ( $line ) {
}
$valueMsgs = $settings[self::PARAM_HELP_MSG_PER_VALUE];
- $deprecatedValues = isset( $settings[self::PARAM_DEPRECATED_VALUES] )
- ? $settings[self::PARAM_DEPRECATED_VALUES]
- : [];
+ $deprecatedValues = $settings[self::PARAM_DEPRECATED_VALUES] ?? [];
foreach ( $settings[self::PARAM_TYPE] as $value ) {
if ( isset( $valueMsgs[$value] ) ) {
if ( !$msg instanceof IApiMessage ) {
$key = $msg->getKey();
$params = $msg->getParams();
- array_unshift( $params, isset( self::$messageMap[$key] ) ? self::$messageMap[$key] : $key );
+ array_unshift( $params, self::$messageMap[$key] ?? $key );
$msg = ApiMessage::create( $params );
}
$flagText = '[' . implode( ', ', $flags ) . ']';
}
- $blockedFile = isset( $report['blocked-uri'] ) ? $report['blocked-uri'] : 'n/a';
- $page = isset( $report['document-uri'] ) ? $report['document-uri'] : 'n/a';
+ $blockedFile = $report['blocked-uri'] ?? 'n/a';
+ $page = $report['document-uri'] ?? 'n/a';
$line = isset( $report['line-number'] ) ? ':' . $report['line-number'] : '';
$warningText = $flagText .
' Received CSP report: <' . $blockedFile .
public function formatException( $exception, array $options = [] ) {
return $this->formatMessage(
$this->getMessageFromException( $exception, $options ),
- isset( $options['format'] ) ? $options['format'] : null
+ $options['format'] ?? null
);
}
' [' . $this->getConfig()->get( 'LanguageCode' ) . ']';
$feedUrl = SpecialPage::getTitleFor( 'Watchlist' )->getFullURL();
- $feedFormat = isset( $params['feedformat'] ) ? $params['feedformat'] : 'rss';
+ $feedFormat = $params['feedformat'] ?? 'rss';
$msg = wfMessage( 'watchlist' )->inContentLanguage()->escaped();
$feed = new $feedClasses[$feedFormat] ( $feedTitle, $msg, $feedUrl );
} else {
$titleUrl = $title->getFullURL( $curidParam );
}
- $comment = isset( $info['comment'] ) ? $info['comment'] : null;
+ $comment = $info['comment'] ?? null;
// Create an anchor to section.
// The anchor won't work for sections that have dupes on page
$value = (array)$value;
}
if ( is_array( $value ) ) {
- $contentKey = isset( $value[ApiResult::META_CONTENT] )
- ? $value[ApiResult::META_CONTENT]
- : '*';
- $subelementKeys = isset( $value[ApiResult::META_SUBELEMENTS] )
- ? $value[ApiResult::META_SUBELEMENTS]
- : [];
+ $contentKey = $value[ApiResult::META_CONTENT] ?? '*';
+ $subelementKeys = $value[ApiResult::META_SUBELEMENTS] ?? [];
if ( isset( $value[ApiResult::META_BC_SUBELEMENTS] ) ) {
$subelementKeys = array_merge(
$subelementKeys, $value[ApiResult::META_BC_SUBELEMENTS]
);
}
- $preserveKeys = isset( $value[ApiResult::META_PRESERVE_KEYS] )
- ? $value[ApiResult::META_PRESERVE_KEYS]
- : [];
+ $preserveKeys = $value[ApiResult::META_PRESERVE_KEYS] ?? [];
$indexedTagName = isset( $value[ApiResult::META_INDEXED_TAG_NAME] )
? self::mangleName( $value[ApiResult::META_INDEXED_TAG_NAME], $preserveKeys )
: '_v';
- $bcBools = isset( $value[ApiResult::META_BC_BOOLS] )
- ? $value[ApiResult::META_BC_BOOLS]
- : [];
+ $bcBools = $value[ApiResult::META_BC_BOOLS] ?? [];
$indexSubelements = isset( $value[ApiResult::META_TYPE] )
? $value[ApiResult::META_TYPE] !== 'array'
: false;
}
$out->addHTML( $html );
- $helptitle = isset( $options['helptitle'] ) ? $options['helptitle'] : null;
+ $helptitle = $options['helptitle'] ?? null;
$html = self::fixHelpLinks( $out->getHTML(), $helptitle, $haveModules );
$out->clearHTML();
$out->addHTML( $html );
// Type documentation
if ( !isset( $settings[ApiBase::PARAM_TYPE] ) ) {
- $dflt = isset( $settings[ApiBase::PARAM_DFLT] )
- ? $settings[ApiBase::PARAM_DFLT]
- : null;
+ $dflt = $settings[ApiBase::PARAM_DFLT] ?? null;
if ( is_bool( $dflt ) ) {
$settings[ApiBase::PARAM_TYPE] = 'boolean';
} elseif ( is_string( $dflt ) || is_null( $dflt ) ) {
if ( is_array( $type ) ) {
$count = count( $type );
- $deprecatedValues = isset( $settings[ApiBase::PARAM_DEPRECATED_VALUES] )
- ? $settings[ApiBase::PARAM_DEPRECATED_VALUES]
- : [];
- $links = isset( $settings[ApiBase::PARAM_VALUE_LINKS] )
- ? $settings[ApiBase::PARAM_VALUE_LINKS]
- : [];
+ $deprecatedValues = $settings[ApiBase::PARAM_DEPRECATED_VALUES] ?? [];
+ $links = $settings[ApiBase::PARAM_VALUE_LINKS] ?? [];
$values = array_map( function ( $v ) use ( $links, $deprecatedValues ) {
$attr = [];
if ( $v !== '' ) {
$info[] = implode( ' ', $extra );
}
- $allowAll = isset( $settings[ApiBase::PARAM_ALL] )
- ? $settings[ApiBase::PARAM_ALL]
- : false;
+ $allowAll = $settings[ApiBase::PARAM_ALL] ?? false;
if ( $allowAll || $settings[ApiBase::PARAM_TYPE] === 'namespace' ) {
if ( $settings[ApiBase::PARAM_TYPE] === 'namespace' ) {
$allSpecifier = ApiBase::ALL_DEFAULT_STRING;
}
// Add default
- $default = isset( $settings[ApiBase::PARAM_DFLT] )
- ? $settings[ApiBase::PARAM_DFLT]
- : null;
+ $default = $settings[ApiBase::PARAM_DFLT] ?? null;
if ( $default === '' ) {
$info[] = $context->msg( 'api-help-param-default-empty' )
->parse();
foreach ( $modules as $name => $moduleSpec ) {
if ( is_array( $moduleSpec ) ) {
$class = $moduleSpec['class'];
- $factory = ( isset( $moduleSpec['factory'] ) ? $moduleSpec['factory'] : null );
+ $factory = ( $moduleSpec['factory'] ?? null );
} else {
$class = $moduleSpec;
$factory = null;
if ( $params['change'] ) {
foreach ( $params['change'] as $entry ) {
$array = explode( '=', $entry, 2 );
- $changes[$array[0]] = isset( $array[1] ) ? $array[1] : null;
+ $changes[$array[0]] = $array[1] ?? null;
}
}
if ( isset( $params['optionname'] ) ) {
- $newValue = isset( $params['optionvalue'] ) ? $params['optionvalue'] : null;
+ $newValue = $params['optionvalue'] ?? null;
$changes[$params['optionname']] = $newValue;
}
if ( !$changed && !count( $changes ) ) {
}
if ( !isset( $settings[ApiBase::PARAM_TYPE] ) ) {
- $dflt = isset( $settings[ApiBase::PARAM_DFLT] )
- ? $settings[ApiBase::PARAM_DFLT]
- : null;
+ $dflt = $settings[ApiBase::PARAM_DFLT] ?? null;
if ( is_bool( $dflt ) ) {
$settings[ApiBase::PARAM_TYPE] = 'boolean';
} elseif ( is_string( $dflt ) || is_null( $dflt ) ) {
$allowAll = true;
$allSpecifier = ApiBase::ALL_DEFAULT_STRING;
} else {
- $allowAll = isset( $settings[ApiBase::PARAM_ALL] )
- ? $settings[ApiBase::PARAM_ALL]
- : false;
+ $allowAll = $settings[ApiBase::PARAM_ALL] ?? false;
$allSpecifier = ( is_string( $allowAll ) ? $allowAll : ApiBase::ALL_DEFAULT_STRING );
}
if ( $allowAll && $item['multi'] &&
$settings = self::$settings[$this->getModuleName()];
$name = $this->getModuleName();
$path = $this->getModulePath();
- $title = isset( $settings['exampletitle'] ) ? $settings['exampletitle'] : 'Main Page';
+ $title = $settings['exampletitle'] ?? 'Main Page';
$etitle = rawurlencode( $title );
return [
}
$this->addOption( 'LIMIT', $params['limit'] + 1 );
- $offset = isset( $params['offset'] ) ? $params['offset'] : 0;
+ $offset = $params['offset'] ?? 0;
if ( $offset ) {
$this->addOption( 'OFFSET', $params['offset'] );
}
$fit = $this->appendMagicWords( $p );
break;
case 'interwikimap':
- $filteriw = isset( $params['filteriw'] ) ? $params['filteriw'] : false;
+ $filteriw = $params['filteriw'] ?? false;
$fit = $this->appendInterwikiMap( $p, $filteriw );
break;
case 'dbrepllag':
}
$params = $this->extractRequestParams();
- $langCode = isset( $params['inlanguagecode'] ) ? $params['inlanguagecode'] : '';
+ $langCode = $params['inlanguagecode'] ?? '';
$langNames = Language::fetchLanguageNames( $langCode );
$getPrefixes = MediaWikiServices::getInstance()->getInterwikiLookup()->getAllPrefixes( $local );
}
if ( SpecialVersion::getExtLicenseFileName( $extensionPath ) ) {
- $ret['license-name'] = isset( $ext['license-name'] ) ? $ext['license-name'] : '';
+ $ret['license-name'] = $ext['license-name'] ?? '';
$ret['license'] = SpecialPage::getTitleFor(
'Version',
"License/{$ext['name']}"
public function appendLanguages( $property ) {
$params = $this->extractRequestParams();
- $langCode = isset( $params['inlanguagecode'] ) ? $params['inlanguagecode'] : '';
+ $langCode = $params['inlanguagecode'] ?? '';
$langNames = Language::fetchLanguageNames( $langCode );
$data = [];
&& !is_null( $row->rev_len )
&& !is_null( $row->rev_parent_id )
) {
- $parentLen = isset( $this->parentLens[$row->rev_parent_id] )
- ? $this->parentLens[$row->rev_parent_id]
- : 0;
+ $parentLen = $this->parentLens[$row->rev_parent_id] ?? 0;
$vals['sizediff'] = intval( $row->rev_len - $parentLen );
}
* @return array|object
*/
protected static function applyTransformations( array $dataIn, array $transforms ) {
- $strip = isset( $transforms['Strip'] ) ? $transforms['Strip'] : 'none';
+ $strip = $transforms['Strip'] ?? 'none';
if ( $strip === 'base' ) {
$transforms['Strip'] = 'none';
}
- $transformTypes = isset( $transforms['Types'] ) ? $transforms['Types'] : null;
+ $transformTypes = $transforms['Types'] ?? null;
if ( $transformTypes !== null && !is_array( $transformTypes ) ) {
throw new InvalidArgumentException( __METHOD__ . ':Value for "Types" must be an array' );
}
case 'kvp':
case 'BCkvp':
- $key = isset( $metadata[self::META_KVP_KEY_NAME] )
- ? $metadata[self::META_KVP_KEY_NAME]
- : $transformTypes['ArmorKVP'];
+ $key = $metadata[self::META_KVP_KEY_NAME] ?? $transformTypes['ArmorKVP'];
$valKey = isset( $transforms['BC'] ) ? '*' : 'value';
$assocAsObject = !empty( $transformTypes['AssocAsObject'] );
$merge = !empty( $metadata[self::META_KVP_MERGE] );
'name' => $name,
'preferred' => wfBoolToStr( $name == 'MediaWiki' ),
'apiLink' => $info['apiLink'],
- 'blogID' => isset( $info['blogID'] ) ? $info['blogID'] : '',
+ 'blogID' => $info['blogID'] ?? '',
];
$settings = [];
if ( isset( $info['docs'] ) ) {
$pa = new PageArchive( $titleObj, $this->getConfig() );
$retval = $pa->undelete(
- ( isset( $params['timestamps'] ) ? $params['timestamps'] : [] ),
+ ( $params['timestamps'] ?? [] ),
$params['reason'],
$params['fileids'],
false,
$warning = $warnings['exists'];
unset( $warnings['exists'] );
/** @var LocalFile $localFile */
- $localFile = isset( $warning['normalizedFile'] )
- ? $warning['normalizedFile']
- : $warning['file'];
+ $localFile = $warning['normalizedFile'] ?? $warning['file'];
$warnings[$warning['warning']] = $localFile->getName();
}
$this->requireOnlyOneParameter( $params, 'user', 'userid' );
- $user = isset( $params['user'] ) ? $params['user'] : '#' . $params['userid'];
+ $user = $params['user'] ?? '#' . $params['userid'];
$form = $this->getUserRightsPage();
$form->setContext( $this->getContext() );
*/
public function buildSearchEngine( array $params = null ) {
if ( $params != null ) {
- $type = isset( $params['backend'] ) ? $params['backend'] : null;
+ $type = $params['backend'] ?? null;
if ( $type === self::$BACKEND_NULL_PARAM ) {
$type = null;
}
}
// Checks passed, create the user...
- $from = isset( $_SERVER['REQUEST_URI'] ) ? $_SERVER['REQUEST_URI'] : 'CLI';
+ $from = $_SERVER['REQUEST_URI'] ?? 'CLI';
$this->logger->info( __METHOD__ . ': creating new user ({username}) - from: {from}', [
'username' => $username,
'from' => $from,
}
}
- $needReq = isset( $data->req ) ? $data->req : new PasswordAuthenticationRequest();
+ $needReq = $data->req ?? new PasswordAuthenticationRequest();
if ( !$needReq->action ) {
$needReq->action = AuthManager::ACTION_CHANGE;
}
public function __construct( $params = [] ) {
$this->throttleSettings = array_intersect_key( $params,
[ 'accountCreationThrottle' => true, 'passwordAttemptThrottle' => true ] );
- $this->cache = isset( $params['cache'] ) ? $params['cache'] :
- \ObjectCache::getLocalClusterInstance();
+ $this->cache = $params['cache'] ?? \ObjectCache::getLocalClusterInstance();
}
public function setConfig( Config $config ) {
/* Undefined if there is a valid username which for some reason doesn't
* exist in the database.
*/
- return isset( $this->cache[$username] ) ? $this->cache[$username] : $this->getDefault();
+ return $this->cache[$username] ?? $this->getDefault();
}
/**
$this->wanCache->makeKey( 'messages', $code, 'hash', 'v1' ),
[
'hash' => $cache['HASH'],
- 'latest' => isset( $cache['LATEST'] ) ? $cache['LATEST'] : 0
+ 'latest' => $cache['LATEST'] ?? 0
],
WANObjectCache::TTL_INDEFINITE
);
$this->doQuery( [ $userId ] ); // cache miss
}
- return isset( $this->cache[$userId][$prop] )
- ? $this->cache[$userId][$prop]
- : false; // user does not exist?
+ return $this->cache[$userId][$prop] ?? false; // user does not exist?
}
/**
$flagInfos[$key]['letter'] = $value['letter'];
$flagInfos[$key]['title'] = $value['title'];
// Allow customized class name, fall back to flag name
- $flagInfos[$key]['class'] = isset( $value['class'] ) ? $value['class'] : $key;
+ $flagInfos[$key]['class'] = $value['class'] ?? $key;
}
}
'id' => $rc->mAttribs['rc_this_oldid'],
'user' => $rc->mAttribs['rc_user'],
'user_text' => $rc->mAttribs['rc_user_text'],
- 'actor' => isset( $rc->mAttribs['rc_actor'] ) ? $rc->mAttribs['rc_actor'] : null,
+ 'actor' => $rc->mAttribs['rc_actor'] ?? null,
'deleted' => $rc->mAttribs['rc_deleted']
] );
$s .= ' ' . Linker::generateRollback( $rev, $this->getContext() );
* @return ChangesListFilter|null Specified filter, or null if it is not registered
*/
public function getFilter( $name ) {
- return isset( $this->filters[$name] ) ? $this->filters[$name] : null;
+ return $this->filters[$name] ?? null;
}
/**
# Default values for RC flags
$collectedRcFlags = [];
foreach ( $recentChangesFlags as $key => $value ) {
- $flagGrouping = ( isset( $recentChangesFlags[$key]['grouping'] ) ?
- $recentChangesFlags[$key]['grouping'] : 'any' );
+ $flagGrouping = ( $recentChangesFlags[$key]['grouping'] ?? 'any' );
switch ( $flagGrouping ) {
case 'all':
$collectedRcFlags[$key] = true;
// Roll up flags
foreach ( $line['recentChangesFlagsRaw'] as $key => $value ) {
- $flagGrouping = ( isset( $recentChangesFlags[$key]['grouping'] ) ?
- $recentChangesFlags[$key]['grouping'] : 'any' );
+ $flagGrouping = ( $recentChangesFlags[$key]['grouping'] ?? 'any' );
switch ( $flagGrouping ) {
case 'all':
if ( !$value ) {
# Convert mAttribs['rc_user'] etc for ActorMigration
$user = User::newFromAnyId(
- isset( $row['rc_user'] ) ? $row['rc_user'] : null,
- isset( $row['rc_user_text'] ) ? $row['rc_user_text'] : null,
- isset( $row['rc_actor'] ) ? $row['rc_actor'] : null
+ $row['rc_user'] ?? null,
+ $row['rc_user_text'] ?? null,
+ $row['rc_actor'] ?? null
);
unset( $row['rc_user'], $row['rc_user_text'], $row['rc_actor'] );
$row += ActorMigration::newMigration()->getInsertValues( $dbw, 'rc_user', $user );
*/
public function getParam( $name ) {
$params = $this->parseParams();
- return isset( $params[$name] ) ? $params[$name] : null;
+ return $params[$name] ?? null;
}
/**
$this->mAttribs['rc_comment_data'] = null;
$user = User::newFromAnyId(
- isset( $this->mAttribs['rc_user'] ) ? $this->mAttribs['rc_user'] : null,
- isset( $this->mAttribs['rc_user_text'] ) ? $this->mAttribs['rc_user_text'] : null,
- isset( $this->mAttribs['rc_actor'] ) ? $this->mAttribs['rc_actor'] : null
+ $this->mAttribs['rc_user'] ?? null,
+ $this->mAttribs['rc_user_text'] ?? null,
+ $this->mAttribs['rc_actor'] ?? null
);
$this->mAttribs['rc_user'] = $user->getId();
$this->mAttribs['rc_user_text'] = $user->getName();
if ( $name === 'rc_user' || $name === 'rc_user_text' || $name === 'rc_actor' ) {
$user = User::newFromAnyId(
- isset( $this->mAttribs['rc_user'] ) ? $this->mAttribs['rc_user'] : null,
- isset( $this->mAttribs['rc_user_text'] ) ? $this->mAttribs['rc_user_text'] : null,
- isset( $this->mAttribs['rc_actor'] ) ? $this->mAttribs['rc_actor'] : null
+ $this->mAttribs['rc_user'] ?? null,
+ $this->mAttribs['rc_user_text'] ?? null,
+ $this->mAttribs['rc_actor'] ?? null
);
if ( $name === 'rc_user' ) {
return $user->getId();
}
}
- return isset( $this->mAttribs[$name] ) ? $this->mAttribs[$name] : null;
+ return $this->mAttribs[$name] ?? null;
}
/**
// store the tag usage statistics
$tagUsage = self::tagUsageStatistics();
- $hitcount = isset( $tagUsage[$tag] ) ? $tagUsage[$tag] : 0;
+ $hitcount = $tagUsage[$tag] ?? 0;
// do it!
$deleteResult = self::deleteTagEverywhere( $tag );
public function __construct( $server, $options = [] ) {
$parts = explode( ':', $server, 2 );
$this->host = $parts[0];
- $this->port = isset( $parts[1] ) ? $parts[1] : 80;
+ $this->port = $parts[1] ?? 80;
}
/**
if ( !isset( $this->singletons['loggers'][$channel] ) ) {
// Fallback to using the '@default' configuration if an explict
// configuration for the requested channel isn't found.
- $spec = isset( $this->config['loggers'][$channel] ) ?
- $this->config['loggers'][$channel] :
- $this->config['loggers']['@default'];
+ $spec = $this->config['loggers'][$channel] ?? $this->config['loggers']['@default'];
$monolog = $this->createLogger( $channel, $spec );
$this->singletons['loggers'][$channel] = $monolog;
);
}
- $prev = isset( $prev['previous'] ) ? $prev['previous'] : null;
+ $prev = $prev['previous'] ?? null;
}
}
return $str;
public function getSlave( $cluster ) {
global $wgDefaultExternalStore;
- $wiki = isset( $this->params['wiki'] ) ? $this->params['wiki'] : false;
+ $wiki = $this->params['wiki'] ?? false;
$lb = $this->getLoadBalancer( $cluster );
if ( !in_array( "DB://" . $cluster, (array)$wgDefaultExternalStore ) ) {
* @return MaintainableDBConnRef
*/
public function getMaster( $cluster ) {
- $wiki = isset( $this->params['wiki'] ) ? $this->params['wiki'] : false;
+ $wiki = $this->params['wiki'] ?? false;
$lb = $this->getLoadBalancer( $cluster );
$db = $lb->getMaintenanceConnectionRef( DB_MASTER, [], $wiki );
return [
$path[2], // cluster
$path[3], // id
- isset( $path[4] ) ? $path[4] : false // itemID
+ $path[4] ?? false // itemID
];
}
}
// Make sure ID is roughly lexicographically increasing for performance
$id = str_pad( UIDGenerator::newTimestampedUID128( 32 ), 26, '0', STR_PAD_LEFT );
// Segregate items by wiki ID for the sake of bookkeeping
- $wiki = isset( $this->params['wiki'] ) ? $this->params['wiki'] : wfWikiID();
+ $wiki = $this->params['wiki'] ?? wfWikiID();
$url = $be->getContainerStoragePath( 'data' ) . '/' . rawurlencode( $wiki );
$url .= ( $be instanceof FSFileBackend )
$repoName = $info['name'];
// Local vars that used to be FSRepo members...
$directory = $info['directory'];
- $deletedDir = isset( $info['deletedDir'] )
- ? $info['deletedDir']
- : false; // deletion disabled
- $thumbDir = isset( $info['thumbDir'] )
- ? $info['thumbDir']
- : "{$directory}/thumb";
- $transcodedDir = isset( $info['transcodedDir'] )
- ? $info['transcodedDir']
- : "{$directory}/transcoded";
+ $deletedDir = $info['deletedDir'] ?? false; // deletion disabled
+ $thumbDir = $info['thumbDir'] ?? "{$directory}/thumb";
+ $transcodedDir = $info['transcodedDir'] ?? "{$directory}/transcoded";
// Get the FS backend configuration
$autoBackends[] = [
'name' => $backendName,
"{$repoName}-deleted" => $deletedDir,
"{$repoName}-temp" => "{$directory}/temp"
],
- 'fileMode' => isset( $info['fileMode'] ) ? $info['fileMode'] : 0644,
+ 'fileMode' => $info['fileMode'] ?? 0644,
'directoryMode' => $wgDirectoryMode,
];
}
}
// Optional settings that have a default
- $this->initialCapital = isset( $info['initialCapital'] )
- ? $info['initialCapital']
- : MWNamespace::isCapitalized( NS_FILE );
- $this->url = isset( $info['url'] )
- ? $info['url']
- : false; // a subclass may set the URL (e.g. ForeignAPIRepo)
+ $this->initialCapital = $info['initialCapital'] ?? MWNamespace::isCapitalized( NS_FILE );
+ $this->url = $info['url'] ?? false; // a subclass may set the URL (e.g. ForeignAPIRepo)
if ( isset( $info['thumbUrl'] ) ) {
$this->thumbUrl = $info['thumbUrl'];
} else {
$this->thumbUrl = $this->url ? "{$this->url}/thumb" : false;
}
- $this->hashLevels = isset( $info['hashLevels'] )
- ? $info['hashLevels']
- : 2;
- $this->deletedHashLevels = isset( $info['deletedHashLevels'] )
- ? $info['deletedHashLevels']
- : $this->hashLevels;
+ $this->hashLevels = $info['hashLevels'] ?? 2;
+ $this->deletedHashLevels = $info['deletedHashLevels'] ?? $this->hashLevels;
$this->transformVia404 = !empty( $info['transformVia404'] );
- $this->abbrvThreshold = isset( $info['abbrvThreshold'] )
- ? $info['abbrvThreshold']
- : 255;
+ $this->abbrvThreshold = $info['abbrvThreshold'] ?? 255;
$this->isPrivate = !empty( $info['isPrivate'] );
// Give defaults for the basic zones...
- $this->zones = isset( $info['zones'] ) ? $info['zones'] : [];
+ $this->zones = $info['zones'] ?? [];
foreach ( [ 'public', 'thumb', 'transcoded', 'temp', 'deleted' ] as $zone ) {
if ( !isset( $this->zones[$zone]['container'] ) ) {
$this->zones[$zone]['container'] = "{$this->name}-{$zone}";
if ( isset( $options['bypassCache'] ) ) {
$options['latest'] = $options['bypassCache']; // b/c
}
- $time = isset( $options['time'] ) ? $options['time'] : false;
+ $time = $options['time'] ?? false;
$flags = !empty( $options['latest'] ) ? File::READ_LATEST : 0;
# First try the current version of the file to see if it precedes the timestamp
$img = $this->newFile( $title );
* @return File|bool False on failure
*/
public function findFileFromKey( $sha1, $options = [] ) {
- $time = isset( $options['time'] ) ? $options['time'] : false;
+ $time = $options['time'] ?? false;
# First try to find a matching current version of a file...
if ( !$this->fileFactoryKey ) {
return false; // find-by-sha1 not supported
*/
public function getTempHashPath( $suffix ) {
$parts = explode( '!', $suffix, 2 ); // format is <timestamp>!<name> or just <name>
- $name = isset( $parts[1] ) ? $parts[1] : $suffix; // hash path is not based on timestamp
+ $name = $parts[1] ?? $suffix; // hash path is not based on timestamp
return self::getHashPathForLevel( $name, $this->hashLevels );
}
list( $src, $dstRel, $archiveRel ) = $ntuple;
$srcPath = ( $src instanceof FSFile ) ? $src->getPath() : $src;
- $options = isset( $ntuple[3] ) ? $ntuple[3] : [];
+ $options = $ntuple[3] ?? [];
// Resolve source to a storage path if virtual
$srcPath = $this->resolveToStoragePath( $srcPath );
if ( !$this->validateFilename( $dstRel ) ) {
}
// Set any desired headers to be use in GET/HEAD responses
- $headers = isset( $options['headers'] ) ? $options['headers'] : [];
+ $headers = $options['headers'] ?? [];
// Archive destination file if it exists.
// This will check if the archive file also exists and fail if does.
parent::__construct( $info );
// https://commons.wikimedia.org/w/api.php
- $this->mApiBase = isset( $info['apibase'] ) ? $info['apibase'] : null;
+ $this->mApiBase = $info['apibase'] ?? null;
if ( isset( $info['apiThumbCacheExpiry'] ) ) {
$this->apiThumbCacheExpiry = $info['apiThumbCacheExpiry'];
&& empty( $options['private'] )
&& empty( $options['latest'] )
) {
- $time = isset( $options['time'] ) ? $options['time'] : '';
+ $time = $options['time'] ?? '';
if ( $this->cache->has( $dbkey, $time, 60 ) ) {
return $this->cache->get( $dbkey, $time );
}
*/
function getUnscaledThumb( $handlerParams = [] ) {
$hp =& $handlerParams;
- $page = isset( $hp['page'] ) ? $hp['page'] : false;
+ $page = $hp['page'] ?? false;
$width = $this->getWidth( $page );
if ( !$width ) {
return $this->iconThumb();
// Note, the this->canRender() check above implies
// that we have a handler, and it can do makeParamString.
$otherParams = $this->handler->makeParamString( $params );
- $width = isset( $params['width'] ) ? $params['width'] : -1;
- $height = isset( $params['height'] ) ? $params['height'] : -1;
+ $width = $params['width'] ?? -1;
+ $height = $params['height'] ?? -1;
$thumbUrl = $this->repo->getThumbUrlFromCache(
$this->getName(),
* @return bool|string
*/
function getDescriptionUrl() {
- return isset( $this->mInfo['descriptionurl'] )
- ? $this->mInfo['descriptionurl']
- : false;
+ return $this->mInfo['descriptionurl'] ?? false;
}
/**
->getComment( 'description', (object)$decoded )->text;
$decoded['user'] = User::newFromAnyId(
- isset( $decoded['user'] ) ? $decoded['user'] : null,
- isset( $decoded['user_text'] ) ? $decoded['user_text'] : null,
- isset( $decoded['actor'] ) ? $decoded['actor'] : null
+ $decoded['user'] ?? null,
+ $decoded['user_text'] ?? null,
+ $decoded['actor'] ?? null
);
unset( $decoded['user_text'], $decoded['actor'] );
if ( isset( $info['user'] ) || isset( $info['user_text'] ) || isset( $info['actor'] ) ) {
$this->user = User::newFromAnyId(
- isset( $info['user'] ) ? $info['user'] : null,
- isset( $info['user_text'] ) ? $info['user_text'] : null,
- isset( $info['actor'] ) ? $info['actor'] : null
+ $info['user'] ?? null,
+ $info['user_text'] ?? null,
+ $info['actor'] ?? null
);
}
function toHTML() {
if ( $this->mPerRow > 0 ) {
$maxwidth = $this->mPerRow * ( $this->mWidths + $this->getAllPadding() );
- $oldStyle = isset( $this->mAttribs['style'] ) ? $this->mAttribs['style'] : '';
+ $oldStyle = $this->mAttribs['style'] ?? '';
# _width is ignored by any sane browser. IE6 doesn't know max-width
# so it uses _width instead
$this->mAttribs['style'] = "max-width: {$maxwidth}px;_width: {$maxwidth}px;" .
$this->mFlatFields = [];
foreach ( $descriptor as $fieldname => $info ) {
- $section = isset( $info['section'] )
- ? $info['section']
- : '';
+ $section = $info['section'] ?? '';
if ( isset( $info['type'] ) && $info['type'] === 'file' ) {
$this->mUseMultipart = true;
if ( $section === null ) {
return $this->mHeader;
} else {
- return isset( $this->mSectionHeaders[$section] ) ? $this->mSectionHeaders[$section] : '';
+ return $this->mSectionHeaders[$section] ?? '';
}
}
if ( $section === null ) {
return $this->mFooter;
} else {
- return isset( $this->mSectionFooters[$section] ) ? $this->mSectionFooters[$section] : '';
+ return $this->mSectionFooters[$section] ?? '';
}
}
$data = [
'name' => $args[0],
'value' => $args[1],
- 'id' => isset( $args[2] ) ? $args[2] : null,
- 'attribs' => isset( $args[3] ) ? $args[3] : null,
+ 'id' => $args[2] ?? null,
+ 'attribs' => $args[3] ?? null,
];
} else {
if ( !isset( $data['name'] ) ) {
public function initializeHTMLFormElement( array $config = [] ) {
// Properties
- $this->hideIf = isset( $config['hideIf'] ) ? $config['hideIf'] : null;
- $this->modules = isset( $config['modules'] ) ? $config['modules'] : [];
+ $this->hideIf = $config['hideIf'] ?? null;
+ $this->modules = $config['modules'] ?? [];
// Initialization
if ( $this->hideIf ) {
'mw-htmlform-nolabel' => ( $label === '' )
];
- $horizontalLabel = isset( $this->mParams['horizontal-label'] )
- ? $this->mParams['horizontal-label'] : false;
+ $horizontalLabel = $this->mParams['horizontal-label'] ?? false;
if ( $horizontalLabel ) {
$field = ' ' . $inputHtml . "\n$errors";
$displayFormat = $this->mParent->getDisplayFormat();
$html = '';
- $horizontalLabel = isset( $this->mParams['horizontal-label'] )
- ? $this->mParams['horizontal-label'] : false;
+ $horizontalLabel = $this->mParams['horizontal-label'] ?? false;
if ( $displayFormat === 'table' ) {
$html =
$this->relativeField->getInputOOUI( $value ),
[
'id' => $this->mID,
- 'required' => isset( $this->mParams['required'] ) ? $this->mParams['required'] : false,
+ 'required' => $this->mParams['required'] ?? false,
]
);
}
*/
class HTMLFloatField extends HTMLTextField {
public function getSize() {
- return isset( $this->mParams['size'] ) ? $this->mParams['size'] : 20;
+ return $this->mParams['size'] ?? 20;
}
public function validate( $value, $alldata ) {
* @return string
*/
protected function getInputHTMLForKey( $key, array $values ) {
- $displayFormat = isset( $this->mParams['format'] )
- ? $this->mParams['format']
- : $this->mParent->getDisplayFormat();
+ $displayFormat = $this->mParams['format'] ?? $this->mParent->getDisplayFormat();
// Conveniently, PHP method names are case-insensitive.
$getFieldHtmlMethod = $displayFormat == 'table' ? 'getTableRow' : ( 'get' . $displayFormat );
if ( !isset( $fields['delete'] ) ) {
$name = "{$this->mName}[$key][delete]";
- $label = isset( $this->mParams['delete-button-message'] )
- ? $this->mParams['delete-button-message']
- : 'htmlform-cloner-delete';
+ $label = $this->mParams['delete-button-message'] ?? 'htmlform-cloner-delete';
$field = HTMLForm::loadInputFromParameters( $name, [
'type' => 'submit',
'formnovalidate' => true,
], $html );
$name = "{$this->mName}[create]";
- $label = isset( $this->mParams['create-button-message'] )
- ? $this->mParams['create-button-message']
- : 'htmlform-cloner-create';
+ $label = $this->mParams['create-button-message'] ?? 'htmlform-cloner-create';
$field = HTMLForm::loadInputFromParameters( $name, [
'type' => 'submit',
'formnovalidate' => true,
'or' => false,
'classes' => [ 'mw-htmlform-select-and-other-field' ],
'data' => [
- 'maxlengthUnit' => isset( $this->mParams['maxlength-unit'] )
- ? $this->mParams['maxlength-unit'] : 'bytes'
+ 'maxlengthUnit' => $this->mParams['maxlength-unit'] ?? 'bytes'
],
] );
}
}
public function getSize() {
- return isset( $this->mParams['size'] ) ? $this->mParams['size'] : 45;
+ return $this->mParams['size'] ?? 45;
}
public function validate( $value, $alldata ) {
$this->getOptions();
if ( !in_array( 'other', $this->mOptions, true ) ) {
$msg =
- isset( $params['other'] )
- ? $params['other']
- : wfMessage( 'htmlform-selectorother-other' )->text();
+ $params['other'] ?? wfMessage( 'htmlform-selectorother-other' )->text();
// Have 'other' always as first element
$this->mOptions = [ $msg => 'other' ] + $this->mOptions;
}
*/
class HTMLSizeFilterField extends HTMLIntField {
public function getSize() {
- return isset( $this->mParams['size'] ) ? $this->mParams['size'] : 9;
+ return $this->mParams['size'] ?? 9;
}
public function getInputHTML( $value ) {
}
public function getCols() {
- return isset( $this->mParams['cols'] ) ? $this->mParams['cols'] : static::DEFAULT_COLS;
+ return $this->mParams['cols'] ?? static::DEFAULT_COLS;
}
public function getRows() {
- return isset( $this->mParams['rows'] ) ? $this->mParams['rows'] : static::DEFAULT_ROWS;
+ return $this->mParams['rows'] ?? static::DEFAULT_ROWS;
}
public function getSpellCheck() {
- $val = isset( $this->mParams['spellcheck'] ) ? $this->mParams['spellcheck'] : null;
+ $val = $this->mParams['spellcheck'] ?? null;
if ( is_bool( $val ) ) {
// "spellcheck" attribute literally requires "true" or "false" to work.
return $val === true ? 'true' : 'false';
}
public function getSize() {
- return isset( $this->mParams['size'] ) ? $this->mParams['size'] : 45;
+ return $this->mParams['size'] ?? 45;
}
public function getSpellCheck() {
- $val = isset( $this->mParams['spellcheck'] ) ? $this->mParams['spellcheck'] : null;
+ $val = $this->mParams['spellcheck'] ?? null;
if ( is_bool( $val ) ) {
// "spellcheck" attribute literally requires "true" or "false" to work.
return $val === true ? 'true' : 'false';
}
protected function getType( &$attribs ) {
- $type = isset( $attribs['type'] ) ? $attribs['type'] : 'text';
+ $type = $attribs['type'] ?? 'text';
unset( $attribs['type'] );
# Implement tiny differences between some field variants
} elseif ( $tag == 'revision' || $tag == 'upload' ) {
if ( !isset( $title ) ) {
$title = $this->processTitle( $pageInfo['title'],
- isset( $pageInfo['ns'] ) ? $pageInfo['ns'] : null );
+ $pageInfo['ns'] ?? null );
// $title is either an array of two titles or false.
if ( is_array( $title ) ) {
*/
private function processUpload( $pageInfo, $uploadInfo ) {
$revision = new WikiRevision( $this->config );
- $text = isset( $uploadInfo['text'] ) ? $uploadInfo['text'] : '';
+ $text = $uploadInfo['text'] ?? '';
$revision->setTitle( $pageInfo['_title'] );
$revision->setID( $pageInfo['id'] );
$this->setVar( '_InstallUser',
$option['installdbuser'] );
$this->setVar( '_InstallPassword',
- isset( $option['installdbpass'] ) ? $option['installdbpass'] : "" );
+ $option['installdbpass'] ?? "" );
// Assume that if we're given the installer user, we'll create the account.
$this->setVar( '_CreateDBAccount', true );
// Copy $wgAuthenticationTokenVersion too, if it exists
$this->setVar( 'wgAuthenticationTokenVersion',
- isset( $vars['wgAuthenticationTokenVersion'] )
- ? $vars['wgAuthenticationTokenVersion']
- : null
+ $vars['wgAuthenticationTokenVersion'] ?? null
);
return $status;
private function loadFromArray( $mc ) {
if ( isset( $mc['iw_url'] ) ) {
$url = $mc['iw_url'];
- $local = isset( $mc['iw_local'] ) ? $mc['iw_local'] : 0;
- $trans = isset( $mc['iw_trans'] ) ? $mc['iw_trans'] : 0;
- $api = isset( $mc['iw_api'] ) ? $mc['iw_api'] : '';
- $wikiId = isset( $mc['iw_wikiid'] ) ? $mc['iw_wikiid'] : '';
+ $local = $mc['iw_local'] ?? 0;
+ $trans = $mc['iw_trans'] ?? 0;
+ $api = $mc['iw_api'] ?? '';
+ $wikiId = $mc['iw_wikiid'] ?? '';
return new Interwiki( null, $url, $api, $wikiId, $local, $trans );
}
* @since 1.27
*/
public function getRequestId() {
- return isset( $this->params['requestId'] )
- ? $this->params['requestId']
- : null;
+ return $this->params['requestId'] ?? null;
}
/**
*/
public function getRootJobParams() {
return [
- 'rootJobSignature' => isset( $this->params['rootJobSignature'] )
- ? $this->params['rootJobSignature']
- : null,
- 'rootJobTimestamp' => isset( $this->params['rootJobTimestamp'] )
- ? $this->params['rootJobTimestamp']
- : null
+ 'rootJobSignature' => $this->params['rootJobSignature'] ?? null,
+ 'rootJobTimestamp' => $this->params['rootJobTimestamp'] ?? null
];
}
protected function __construct( array $params ) {
$this->wiki = $params['wiki'];
$this->type = $params['type'];
- $this->claimTTL = isset( $params['claimTTL'] ) ? $params['claimTTL'] : 0;
- $this->maxTries = isset( $params['maxTries'] ) ? $params['maxTries'] : 3;
+ $this->claimTTL = $params['claimTTL'] ?? 0;
+ $this->maxTries = $params['maxTries'] ?? 3;
if ( isset( $params['order'] ) && $params['order'] !== 'any' ) {
$this->order = $params['order'];
} else {
throw new MWException( __CLASS__ . " does not support '{$this->order}' order." );
}
$this->dupCache = wfGetCache( CACHE_ANYTHING );
- $this->aggr = isset( $params['aggregator'] )
- ? $params['aggregator']
- : new JobQueueAggregatorNull( [] );
- $this->readOnlyReason = isset( $params['readOnlyReason'] )
- ? $params['readOnlyReason']
- : false;
+ $this->aggr = $params['aggregator'] ?? new JobQueueAggregatorNull( [] );
+ $this->readOnlyReason = $params['readOnlyReason'] ?? false;
}
/**
protected function __construct( array $params ) {
parent::__construct( $params );
- $this->cluster = isset( $params['cluster'] ) ? $params['cluster'] : false;
+ $this->cluster = $params['cluster'] ?? false;
$this->cache = ObjectCache::getMainWANInstance();
}
*/
protected function __construct( array $params ) {
parent::__construct( $params );
- $section = isset( $params['sectionsByWiki'][$this->wiki] )
- ? $params['sectionsByWiki'][$this->wiki]
- : 'default';
+ $section = $params['sectionsByWiki'][$this->wiki] ?? 'default';
if ( !isset( $params['partitionsBySection'][$section] ) ) {
throw new MWException( "No configuration for section '$section'." );
}
- $this->maxPartitionsTry = isset( $params['maxPartitionsTry'] )
- ? $params['maxPartitionsTry']
- : 2;
+ $this->maxPartitionsTry = $params['maxPartitionsTry'] ?? 2;
// Get the full partition map
$partitionMap = $params['partitionsBySection'][$section];
arsort( $partitionMap, SORT_NUMERIC );
parent::__construct( $params );
$params['redisConfig']['serializer'] = 'none'; // make it easy to use Lua
$this->server = $params['redisServer'];
- $this->compression = isset( $params['compression'] ) ? $params['compression'] : 'none';
+ $this->compression = $params['compression'] ?? 'none';
$this->redisPool = RedisConnectionPool::singleton( $params['redisConfig'] );
if ( empty( $params['daemonized'] ) ) {
throw new InvalidArgumentException(
$conf = [ 'wiki' => $params['wiki'], 'type' => $params['type'] ];
$this->mainQueue = JobQueue::factory( $params['mainqueue'] + $conf );
$this->debugQueue = JobQueue::factory( $params['debugqueue'] + $conf );
- $this->onlyWriteToDebugQueue = isset( $params['readonly'] ) ? $params['readonly'] : false;
+ $this->onlyWriteToDebugQueue = $params['readonly'] ?? false;
// We need to construct parent after creating the main and debug queue
// because super constructor calls some methods we delegate to the main queue.
$response = [ 'jobs' => [], 'reached' => 'none-ready' ];
- $type = isset( $options['type'] ) ? $options['type'] : false;
- $maxJobs = isset( $options['maxJobs'] ) ? $options['maxJobs'] : false;
- $maxTime = isset( $options['maxTime'] ) ? $options['maxTime'] : false;
+ $type = $options['type'] ?? false;
+ $maxJobs = $options['maxJobs'] ?? false;
+ $maxTime = $options['maxTime'] ?? false;
$noThrottle = isset( $options['throttle'] ) && !$options['throttle'];
// Bail if job type is invalid
public function getRootJobParams() {
return [
- 'rootJobSignature' => isset( $this->params['rootJobSignature'] )
- ? $this->params['rootJobSignature']
- : null,
- 'rootJobTimestamp' => isset( $this->params['rootJobTimestamp'] )
- ? $this->params['rootJobTimestamp']
- : null
+ 'rootJobSignature' => $this->params['rootJobSignature'] ?? null,
+ 'rootJobTimestamp' => $this->params['rootJobTimestamp'] ?? null
];
}
*/
public function __construct( array $params ) {
parent::__construct( $params );
- $this->servers = isset( $params['redisServers'] )
- ? $params['redisServers']
- : [ $params['redisServer'] ]; // b/c
+ $this->servers = $params['redisServers'] ?? [ $params['redisServer'] ]; // b/c
$params['redisConfig']['serializer'] = 'none';
$this->redisPool = RedisConnectionPool::singleton( $params['redisConfig'] );
$this->logger = \MediaWiki\Logger\LoggerFactory::getInstance( 'redis' );
}
$factory = MediaWikiServices::getInstance()->getDBLoadBalancerFactory();
- $timestamp = isset( $this->params['timestamp'] ) ? $this->params['timestamp'] : null;
+ $timestamp = $this->params['timestamp'] ?? null;
$page = WikiPage::factory( $this->title ); // title when deleted
$update = new LinksDeletionUpdate( $page, $pageId, $timestamp );
// not expected to invalidate these cache entries too often.
$touchTimestamp = wfTimestampNow();
// If page_touched is higher than this, then something else already bumped it after enqueue
- $condTimestamp = isset( $this->params['rootJobTimestamp'] )
- ? $this->params['rootJobTimestamp']
- : $touchTimestamp;
+ $condTimestamp = $this->params['rootJobTimestamp'] ?? $touchTimestamp;
$dbw = wfGetDB( DB_MASTER );
$factory = MediaWikiServices::getInstance()->getDBLoadBalancerFactory();
$this->params['text'],
$this->params['watch'],
$user,
- isset( $this->params['tags'] ) ? $this->params['tags'] : []
+ $this->params['tags'] ?? []
);
if ( !$status->isGood() ) {
UploadBase::setSessionStatus(
$realBSize = $bSize;
}
- $extraParams = isset( $opts['params'] ) ? $opts['params'] : [];
+ $extraParams = $opts['params'] ?? [];
$jobs = [];
// Combine the first range (of size $bSize) backlinks into leaf jobs
507 => 'Insufficient Storage',
511 => 'Network Authentication Required',
];
- return isset( $statusMessage[$code] ) ? $statusMessage[$code] : null;
+ return $statusMessage[$code] ?? null;
}
/**
// Now get the token type from our type array
$token = substr( $s, $pos, $end - $pos ); // so $end - $pos == strlen( $token )
- $type = isset( $tokenTypes[$token] ) ? $tokenTypes[$token] : self::TYPE_LITERAL;
+ $type = $tokenTypes[$token] ?? self::TYPE_LITERAL;
if ( $newlineFound && isset( $semicolon[$state][$type] ) ) {
// This token triggers the semicolon insertion mechanism of javascript. While we
}
parent::__construct( $baseIterator );
$this->vCallback = $vCallback;
- $this->aCallback = isset( $options['accept'] ) ? $options['accept'] : null;
+ $this->aCallback = $options['accept'] ?? null;
}
public function next() {
throw new Exception( "Request has no 'url' field set." );
}
$this->logger->debug( "{$req['method']}: {$req['url']}" );
- $req['query'] = isset( $req['query'] ) ? $req['query'] : [];
+ $req['query'] = $req['query'] ?? [];
$headers = []; // normalized headers
if ( isset( $req['headers'] ) ) {
foreach ( $req['headers'] as $name => $value ) {
$req['body'] = '';
$req['headers']['content-length'] = 0;
}
- $req['flags'] = isset( $req['flags'] ) ? $req['flags'] : [];
+ $req['flags'] = $req['flags'] ?? [];
$handles[$index] = $this->getCurlHandle( $req, $opts );
if ( count( $reqs ) > 1 ) {
// https://github.com/guzzle/guzzle/issues/349
$ch = curl_init();
curl_setopt( $ch, CURLOPT_CONNECTTIMEOUT,
- isset( $opts['connTimeout'] ) ? $opts['connTimeout'] : $this->connTimeout );
- curl_setopt( $ch, CURLOPT_PROXY, isset( $req['proxy'] ) ? $req['proxy'] : $this->proxy );
+ $opts['connTimeout'] ?? $this->connTimeout );
+ curl_setopt( $ch, CURLOPT_PROXY, $req['proxy'] ?? $this->proxy );
curl_setopt( $ch, CURLOPT_TIMEOUT,
- isset( $opts['reqTimeout'] ) ? $opts['reqTimeout'] : $this->reqTimeout );
+ $opts['reqTimeout'] ?? $this->reqTimeout );
curl_setopt( $ch, CURLOPT_FOLLOWLOCATION, 1 );
curl_setopt( $ch, CURLOPT_MAXREDIRS, 4 );
curl_setopt( $ch, CURLOPT_HEADER, 0 );
public function __construct( array $params = [] ) {
$this->clearMarks();
- $this->setLogger( isset( $params['logger'] ) ? $params['logger'] : new NullLogger() );
+ $this->setLogger( $params['logger'] ?? new NullLogger() );
}
/**
* @return array|null Entry named $name or null if it does not exist.
*/
public function getEntryByName( $name ) {
- return isset( $this->entries[$name] ) ? $this->entries[$name] : null;
+ return $this->entries[$name] ?? null;
}
}
// IPv6 bracketed host
$host = $m[1];
$port = intval( $m[2] );
- $prefix = isset( $m[3] ) ? $m[3] : false;
+ $prefix = $m[3] ?? false;
$domain = AF_INET6;
} elseif ( preg_match( '!^udp:(?://)?([a-zA-Z0-9.-]+):(\d+)(?:/(.*))?$!', $info, $m ) ) {
$host = $m[1];
$host = gethostbyname( $host );
}
$port = intval( $m[2] );
- $prefix = isset( $m[3] ) ? $m[3] : false;
+ $prefix = $m[3] ?? false;
$domain = AF_INET;
} else {
throw new InvalidArgumentException( __METHOD__ . ': Invalid UDP specification' );
$deps[$installed['name']] = [
'version' => ComposerJson::normalizeVersion( $installed['version'] ),
'type' => $installed['type'],
- 'licenses' => isset( $installed['license'] ) ? $installed['license'] : [],
- 'authors' => isset( $installed['authors'] ) ? $installed['authors'] : [],
- 'description' => isset( $installed['description'] ) ? $installed['description'] : '',
+ 'licenses' => $installed['license'] ?? [],
+ 'authors' => $installed['authors'] ?? [],
+ 'description' => $installed['description'] ?? '',
];
}
$deps[$installed['name']] = [
'version' => ComposerJson::normalizeVersion( $installed['version'] ),
'type' => $installed['type'],
- 'licenses' => isset( $installed['license'] ) ? $installed['license'] : [],
- 'authors' => isset( $installed['authors'] ) ? $installed['authors'] : [],
- 'description' => isset( $installed['description'] ) ? $installed['description'] : '',
+ 'licenses' => $installed['license'] ?? [],
+ 'authors' => $installed['authors'] ?? [],
+ 'description' => $installed['description'] ?? '',
];
}
}
}
- $this->fileMode = isset( $config['fileMode'] ) ? $config['fileMode'] : 0644;
- $this->dirMode = isset( $config['directoryMode'] ) ? $config['directoryMode'] : 0777;
+ $this->fileMode = $config['fileMode'] ?? 0644;
+ $this->dirMode = $config['directoryMode'] ?? 0777;
if ( isset( $config['fileOwner'] ) && function_exists( 'posix_getuid' ) ) {
$this->fileOwner = $config['fileOwner'];
// cache this, assuming it doesn't change
throw new InvalidArgumentException(
"Backend domain ID not provided for '{$this->name}'." );
}
- $this->lockManager = isset( $config['lockManager'] )
- ? $config['lockManager']
- : new NullLockManager( [] );
- $this->fileJournal = isset( $config['fileJournal'] )
- ? $config['fileJournal']
- : FileJournal::factory( [ 'class' => NullFileJournal::class ], $this->name );
+ $this->lockManager = $config['lockManager'] ?? new NullLockManager( [] );
+ $this->fileJournal = $config['fileJournal']
+ ?? FileJournal::factory( [ 'class' => NullFileJournal::class ], $this->name );
$this->readOnly = isset( $config['readOnly'] )
? (string)$config['readOnly']
: '';
$this->concurrency = isset( $config['concurrency'] )
? (int)$config['concurrency']
: 50;
- $this->obResetFunc = isset( $config['obResetFunc'] )
- ? $config['obResetFunc']
- : [ $this, 'resetOutputBuffer' ];
- $this->streamMimeFunc = isset( $config['streamMimeFunc'] )
- ? $config['streamMimeFunc']
- : null;
- $this->statusWrapper = isset( $config['statusWrapper'] ) ? $config['statusWrapper'] : null;
-
- $this->profiler = isset( $config['profiler'] ) ? $config['profiler'] : null;
- $this->logger = isset( $config['logger'] ) ? $config['logger'] : new \Psr\Log\NullLogger();
- $this->statusWrapper = isset( $config['statusWrapper'] ) ? $config['statusWrapper'] : null;
- $this->tmpDirectory = isset( $config['tmpDirectory'] ) ? $config['tmpDirectory'] : null;
+ $this->obResetFunc = $config['obResetFunc'] ?? [ $this, 'resetOutputBuffer' ];
+ $this->streamMimeFunc = $config['streamMimeFunc'] ?? null;
+ $this->statusWrapper = $config['statusWrapper'] ?? null;
+
+ $this->profiler = $config['profiler'] ?? null;
+ $this->logger = $config['logger'] ?? new \Psr\Log\NullLogger();
+ $this->statusWrapper = $config['statusWrapper'] ?? null;
+ $this->tmpDirectory = $config['tmpDirectory'] ?? null;
}
public function setLogger( LoggerInterface $logger ) {
*/
protected function resolveFSFileObjects( array $ops ) {
foreach ( $ops as &$op ) {
- $src = isset( $op['src'] ) ? $op['src'] : null;
+ $src = $op['src'] ?? null;
if ( $src instanceof FSFile ) {
$op['srcRef'] = $src;
$op['src'] = $src->getPath();
*/
public function __construct( array $config ) {
parent::__construct( $config );
- $this->syncChecks = isset( $config['syncChecks'] )
- ? $config['syncChecks']
- : self::CHECK_SIZE;
- $this->autoResync = isset( $config['autoResync'] )
- ? $config['autoResync']
- : false;
+ $this->syncChecks = $config['syncChecks'] ?? self::CHECK_SIZE;
+ $this->autoResync = $config['autoResync'] ?? false;
$this->asyncWrites = isset( $config['replication'] ) && $config['replication'] === 'async';
// Construct backends here rather than via registration
// to keep these backends hidden from outside the proxy.
*/
public function __construct( array $config ) {
parent::__construct( $config );
- $this->mimeCallback = isset( $config['mimeCallback'] )
- ? $config['mimeCallback']
- : null;
+ $this->mimeCallback = $config['mimeCallback'] ?? null;
$this->srvCache = new EmptyBagOStuff(); // disabled by default
$this->memCache = WANObjectCache::newEmpty(); // disabled by default
$this->cheapCache = new ProcessCacheLRU( self::CACHE_CHEAP_SIZE );
$stat = $this->doGetFileStat( $params );
if ( is_array( $stat ) ) { // file exists
// Strongly consistent backends can automatically set "latest"
- $stat['latest'] = isset( $stat['latest'] ) ? $stat['latest'] : $latest;
+ $stat['latest'] = $stat['latest'] ?? $latest;
$this->cheapCache->set( $path, 'stat', $stat );
$this->setFileCache( $path, $stat ); // update persistent cache
if ( isset( $stat['sha1'] ) ) { // some backends store SHA-1 as metadata
$status = $this->newStatus();
// Always set some fields for subclass convenience
- $params['options'] = isset( $params['options'] ) ? $params['options'] : [];
- $params['headers'] = isset( $params['headers'] ) ? $params['headers'] : [];
+ $params['options'] = $params['options'] ?? [];
+ $params['headers'] = $params['headers'] ?? [];
// Don't stream it out as text/html if there was a PHP error
if ( ( empty( $params['headless'] ) || $params['headers'] ) && headers_sent() ) {
}
if ( is_array( $stat ) ) { // file exists
// Strongly consistent backends can automatically set "latest"
- $stat['latest'] = isset( $stat['latest'] ) ? $stat['latest'] : $latest;
+ $stat['latest'] = $stat['latest'] ?? $latest;
$this->cheapCache->set( $path, 'stat', $stat );
$this->setFileCache( $path, $stat ); // update persistent cache
if ( isset( $stat['sha1'] ) ) { // some backends store SHA-1 as metadata
$batchId = $journal->getTimestampedUUID();
$ignoreErrors = !empty( $opts['force'] );
$journaled = empty( $opts['nonJournaled'] );
- $maxConcurrency = isset( $opts['concurrency'] ) ? $opts['concurrency'] : 1;
+ $maxConcurrency = $opts['concurrency'] ?? 1;
$entries = []; // file journal entry list
$predicates = FileOp::newPredicates(); // account for previous ops in prechecks
*/
public function __construct( $path, array $params = [] ) {
$this->path = $path;
- $this->obResetFunc = isset( $params['obResetFunc'] )
- ? $params['obResetFunc']
- : [ __CLASS__, 'resetOutputBuffers' ];
- $this->streamMimeFunc = isset( $params['streamMimeFunc'] )
- ? $params['streamMimeFunc']
- : [ __CLASS__, 'contentTypeFromPath' ];
+ $this->obResetFunc = $params['obResetFunc'] ?? [ __CLASS__, 'resetOutputBuffers' ];
+ $this->streamMimeFunc = $params['streamMimeFunc'] ?? [ __CLASS__, 'contentTypeFromPath' ];
}
/**
$this->swiftUser = $config['swiftUser'];
$this->swiftKey = $config['swiftKey'];
// Optional settings
- $this->authTTL = isset( $config['swiftAuthTTL'] )
- ? $config['swiftAuthTTL']
- : 15 * 60; // some sane number
- $this->swiftTempUrlKey = isset( $config['swiftTempUrlKey'] )
- ? $config['swiftTempUrlKey']
- : '';
- $this->swiftStorageUrl = isset( $config['swiftStorageUrl'] )
- ? $config['swiftStorageUrl']
- : null;
- $this->shardViaHashLevels = isset( $config['shardViaHashLevels'] )
- ? $config['shardViaHashLevels']
- : '';
- $this->rgwS3AccessKey = isset( $config['rgwS3AccessKey'] )
- ? $config['rgwS3AccessKey']
- : '';
- $this->rgwS3SecretKey = isset( $config['rgwS3SecretKey'] )
- ? $config['rgwS3SecretKey']
- : '';
+ $this->authTTL = $config['swiftAuthTTL'] ?? 15 * 60; // some sane number
+ $this->swiftTempUrlKey = $config['swiftTempUrlKey'] ?? '';
+ $this->swiftStorageUrl = $config['swiftStorageUrl'] ?? null;
+ $this->shardViaHashLevels = $config['shardViaHashLevels'] ?? '';
+ $this->rgwS3AccessKey = $config['rgwS3AccessKey'] ?? '';
+ $this->rgwS3SecretKey = $config['rgwS3SecretKey'] ?? '';
// HTTP helper client
$this->http = new MultiHttpClient( [] );
// Cache container information to mask latency
} else {
$this->srvCache = new EmptyBagOStuff();
}
- $this->readUsers = isset( $config['readUsers'] )
- ? $config['readUsers']
- : [];
- $this->writeUsers = isset( $config['writeUsers'] )
- ? $config['writeUsers']
- : [];
- $this->secureReadUsers = isset( $config['secureReadUsers'] )
- ? $config['secureReadUsers']
- : [];
- $this->secureWriteUsers = isset( $config['secureWriteUsers'] )
- ? $config['secureWriteUsers']
- : [];
+ $this->readUsers = $config['readUsers'] ?? [];
+ $this->writeUsers = $config['writeUsers'] ?? [];
+ $this->secureReadUsers = $config['secureReadUsers'] ?? [];
+ $this->secureWriteUsers = $config['secureWriteUsers'] ?? [];
}
public function getFeatures() {
}
$sha1Hash = Wikimedia\base_convert( sha1( $params['content'] ), 16, 36, 31 );
- $contentType = isset( $params['headers']['content-type'] )
- ? $params['headers']['content-type']
- : $this->getContentType( $params['dst'], $params['content'], null );
+ $contentType = $params['headers']['content-type']
+ ?? $this->getContentType( $params['dst'], $params['content'], null );
$reqs = [ [
'method' => 'PUT',
return $status;
}
$sha1Hash = Wikimedia\base_convert( $sha1Hash, 16, 36, 31 );
- $contentType = isset( $params['headers']['content-type'] )
- ? $params['headers']['content-type']
- : $this->getContentType( $params['dst'], null, $params['src'] );
+ $contentType = $params['headers']['content-type']
+ ?? $this->getContentType( $params['dst'], null, $params['src'] );
$handle = fopen( $params['src'], 'rb' );
if ( $handle === false ) { // source doesn't exist?
return null;
}
- $ttl = isset( $params['ttl'] ) ? $params['ttl'] : 86400;
+ $ttl = $params['ttl'] ?? 86400;
$expires = time() + $ttl;
if ( $this->swiftTempUrlKey != '' ) {
foreach ( $reqs as $stage => &$req ) {
list( $container, $relPath ) = $req['url'];
$req['url'] = $this->storageUrl( $auth, $container, $relPath );
- $req['headers'] = isset( $req['headers'] ) ? $req['headers'] : [];
+ $req['headers'] = $req['headers'] ?? [];
$req['headers'] = $this->authTokenHeaders( $auth ) + $req['headers'];
$httpReqsByStage[$stage][$index] = $req;
}
'mtime' => $this->convertSwiftDate( $rhdrs['last-modified'], TS_MW ),
// Empty objects actually return no content-length header in Ceph
'size' => isset( $rhdrs['content-length'] ) ? (int)$rhdrs['content-length'] : 0,
- 'sha1' => isset( $metadata['sha1base36'] ) ? $metadata['sha1base36'] : null,
+ 'sha1' => $metadata['sha1base36'] ?? null,
// Note: manifiest ETags are not an MD5 of the file
'md5' => ctype_xdigit( $rhdrs['etag'] ) ? $rhdrs['etag'] : null,
'xattr' => [ 'metadata' => $metadata, 'headers' => $headers ]
* 'ttlDays' : days to keep log entries around (false means "forever")
*/
protected function __construct( array $config ) {
- $this->ttlDays = isset( $config['ttlDays'] ) ? $config['ttlDays'] : false;
+ $this->ttlDays = $config['ttlDays'] ?? false;
}
/**
* @return mixed Returns null if the parameter is not set
*/
final public function getParam( $name ) {
- return isset( $this->params[$name] ) ? $this->params[$name] : null;
+ return $this->params[$name] ?? null;
}
/**
// Tracks peers that couldn't be queried recently to avoid lengthy
// connection timeouts. This is useless if each bucket has one peer.
- $this->statusCache = isset( $config['srvCache'] )
- ? $config['srvCache']
- : new HashBagOStuff();
+ $this->statusCache = $config['srvCache'] ?? new HashBagOStuff();
}
/**
* This only applies if locks are not tied to a connection/process.
*/
public function __construct( array $config ) {
- $this->domain = isset( $config['domain'] ) ? $config['domain'] : 'global';
+ $this->domain = $config['domain'] ?? 'global';
if ( isset( $config['lockTTL'] ) ) {
$this->lockTTL = max( 5, $config['lockTTL'] );
} elseif ( PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg' ) {
}
$this->session = md5( implode( '-', $random ) );
- $this->logger = isset( $config['logger'] ) ? $config['logger'] : new \Psr\Log\NullLogger();
+ $this->logger = $config['logger'] ?? new \Psr\Log\NullLogger();
}
/**
$this->srvsByBucket = array_filter( $config['srvsByBucket'], 'is_array' );
$this->srvsByBucket = array_values( $this->srvsByBucket ); // consecutive
- $memcConfig = isset( $config['memcConfig'] ) ? $config['memcConfig'] : [];
+ $memcConfig = $config['memcConfig'] ?? [];
$memcConfig += [ 'class' => MemcachedPhpBagOStuff::class ]; // default
$class = $memcConfig['class'];
$this->typeFile = $params['typeFile'];
$this->infoFile = $params['infoFile'];
$this->xmlTypes = $params['xmlTypes'];
- $this->initCallback = isset( $params['initCallback'] )
- ? $params['initCallback']
- : null;
- $this->detectCallback = isset( $params['detectCallback'] )
- ? $params['detectCallback']
- : null;
- $this->guessCallback = isset( $params['guessCallback'] )
- ? $params['guessCallback']
- : null;
- $this->extCallback = isset( $params['extCallback'] )
- ? $params['extCallback']
- : null;
- $this->logger = isset( $params['logger'] )
- ? $params['logger']
- : new \Psr\Log\NullLogger();
+ $this->initCallback = $params['initCallback'] ?? null;
+ $this->detectCallback = $params['detectCallback'] ?? null;
+ $this->guessCallback = $params['guessCallback'] ?? null;
+ $this->extCallback = $params['extCallback'] ?? null;
+ $this->logger = $params['logger'] ?? new \Psr\Log\NullLogger();
$this->loadFiles();
}
public function getTypesForExtension( $ext ) {
$ext = strtolower( $ext );
- $r = isset( $this->mExtToMime[$ext] ) ? $this->mExtToMime[$ext] : null;
+ $r = $this->mExtToMime[$ext] ?? null;
return $r;
}
$callbackReturn = call_user_func(
$externalCallback,
$parsedDTD['type'],
- isset( $parsedDTD['publicid'] ) ? $parsedDTD['publicid'] : null,
- isset( $parsedDTD['systemid'] ) ? $parsedDTD['systemid'] : null
+ $parsedDTD['publicid'] ?? null,
+ $parsedDTD['systemid'] ?? null
);
}
if ( $callbackReturn ) {
$this->keyspace = $params['keyspace'];
}
- $this->asyncHandler = isset( $params['asyncHandler'] )
- ? $params['asyncHandler']
- : null;
+ $this->asyncHandler = $params['asyncHandler'] ?? null;
if ( !empty( $params['reportDupes'] ) && is_callable( $this->asyncHandler ) ) {
$this->reportDupes = true;
}
- $this->syncTimeout = isset( $params['syncTimeout'] ) ? $params['syncTimeout'] : 3;
+ $this->syncTimeout = $params['syncTimeout'] ?? 3;
}
/**
* @since 1.28
*/
public function getQoS( $flag ) {
- return isset( $this->attrMap[$flag] ) ? $this->attrMap[$flag] : self::QOS_UNKNOWN;
+ return $this->attrMap[$flag] ?? self::QOS_UNKNOWN;
}
/**
function __construct( $params = [] ) {
parent::__construct( $params );
- $this->maxCacheKeys = isset( $params['maxKeys'] ) ? $params['maxKeys'] : INF;
+ $this->maxCacheKeys = $params['maxKeys'] ?? INF;
if ( $this->maxCacheKeys <= 0 ) {
throw new InvalidArgumentException( '$maxKeys parameter must be above zero' );
}
* @return mixed
*/
public function __construct( $args ) {
- $this->set_servers( isset( $args['servers'] ) ? $args['servers'] : array() );
- $this->_debug = isset( $args['debug'] ) ? $args['debug'] : false;
+ $this->set_servers( $args['servers'] ?? array() );
+ $this->_debug = $args['debug'] ?? false;
$this->stats = array();
- $this->_compress_threshold = isset( $args['compress_threshold'] ) ? $args['compress_threshold'] : 0;
- $this->_persistent = isset( $args['persistent'] ) ? $args['persistent'] : false;
+ $this->_compress_threshold = $args['compress_threshold'] ?? 0;
+ $this->_persistent = $args['persistent'] ?? false;
$this->_compress_enable = true;
$this->_have_zlib = function_exists( 'gzcompress' );
$this->_host_dead = array();
$this->_timeout_seconds = 0;
- $this->_timeout_microseconds = isset( $args['timeout'] ) ? $args['timeout'] : 500000;
+ $this->_timeout_microseconds = $args['timeout'] ?? 500000;
- $this->_connect_timeout = isset( $args['connect_timeout'] ) ? $args['connect_timeout'] : 0.1;
+ $this->_connect_timeout = $args['connect_timeout'] ?? 0.1;
$this->_connect_attempts = 2;
- $this->_logger = isset( $args['logger'] ) ? $args['logger'] : new NullLogger();
+ $this->_logger = $args['logger'] ?? new NullLogger();
}
// }}}
*/
protected function getMasterLinkStatus( RedisConnRef $conn ) {
$info = $conn->info();
- return isset( $info['master_link_status'] )
- ? $info['master_link_status']
- : null;
+ return $info['master_link_status'] ?? null;
}
/**
*/
public function __construct( array $params ) {
$this->cache = $params['cache'];
- $this->purgeChannel = isset( $params['channels']['purge'] )
- ? $params['channels']['purge']
- : self::DEFAULT_PURGE_CHANNEL;
- $this->purgeRelayer = isset( $params['relayers']['purge'] )
- ? $params['relayers']['purge']
- : new EventRelayerNull( [] );
- $this->region = isset( $params['region'] ) ? $params['region'] : 'main';
- $this->cluster = isset( $params['cluster'] ) ? $params['cluster'] : 'wan-main';
+ $this->purgeChannel = $params['channels']['purge'] ?? self::DEFAULT_PURGE_CHANNEL;
+ $this->purgeRelayer = $params['relayers']['purge'] ?? new EventRelayerNull( [] );
+ $this->region = $params['region'] ?? 'main';
+ $this->cluster = $params['cluster'] ?? 'wan-main';
$this->mcrouterAware = !empty( $params['mcrouterAware'] );
- $this->setLogger( isset( $params['logger'] ) ? $params['logger'] : new NullLogger() );
- $this->stats = isset( $params['stats'] ) ? $params['stats'] : new NullStatsdDataFactory();
- $this->asyncHandler = isset( $params['asyncHandler'] ) ? $params['asyncHandler'] : null;
+ $this->setLogger( $params['logger'] ?? new NullLogger() );
+ $this->stats = $params['stats'] ?? new NullStatsdDataFactory();
+ $this->asyncHandler = $params['asyncHandler'] ?? null;
}
/**
$curTTLs = [];
$asOfs = [];
$values = $this->getMulti( [ $key ], $curTTLs, $checkKeys, $asOfs );
- $curTTL = isset( $curTTLs[$key] ) ? $curTTLs[$key] : null;
- $asOf = isset( $asOfs[$key] ) ? $asOfs[$key] : null;
+ $curTTL = $curTTLs[$key] ?? null;
+ $asOf = $asOfs[$key] ?? null;
- return isset( $values[$key] ) ? $values[$key] : false;
+ return $values[$key] ?? false;
}
/**
*/
final public function set( $key, $value, $ttl = 0, array $opts = [] ) {
$now = $this->getCurrentTime();
- $lockTSE = isset( $opts['lockTSE'] ) ? $opts['lockTSE'] : self::TSE_NONE;
- $staleTTL = isset( $opts['staleTTL'] ) ? $opts['staleTTL'] : self::STALE_TTL_NONE;
+ $lockTSE = $opts['lockTSE'] ?? self::TSE_NONE;
+ $staleTTL = $opts['staleTTL'] ?? self::STALE_TTL_NONE;
$age = isset( $opts['since'] ) ? max( 0, $now - $opts['since'] ) : 0;
- $lag = isset( $opts['lag'] ) ? $opts['lag'] : 0;
+ $lag = $opts['lag'] ?? 0;
// Do not cache potentially uncommitted data as it might get rolled back
if ( !empty( $opts['pending'] ) ) {
* @note Callable type hints are not used to avoid class-autoloading
*/
final public function getWithSetCallback( $key, $ttl, $callback, array $opts = [] ) {
- $pcTTL = isset( $opts['pcTTL'] ) ? $opts['pcTTL'] : self::TTL_UNCACHEABLE;
+ $pcTTL = $opts['pcTTL'] ?? self::TTL_UNCACHEABLE;
// Try the process cache if enabled and the cache callback is not within a cache callback.
// Process cache use in nested callbacks is not lag-safe with regard to HOLDOFF_TTL since
// the in-memory value is further lagged than the shared one since it uses a blind TTL.
if ( $pcTTL >= 0 && $this->callbackDepth == 0 ) {
- $group = isset( $opts['pcGroup'] ) ? $opts['pcGroup'] : self::PC_PRIMARY;
+ $group = $opts['pcGroup'] ?? self::PC_PRIMARY;
$procCache = $this->getProcessCache( $group );
$value = $procCache->get( $key );
} else {
* @note Callable type hints are not used to avoid class-autoloading
*/
protected function doGetWithSetCallback( $key, $ttl, $callback, array $opts, &$asOf = null ) {
- $lowTTL = isset( $opts['lowTTL'] ) ? $opts['lowTTL'] : min( self::LOW_TTL, $ttl );
- $lockTSE = isset( $opts['lockTSE'] ) ? $opts['lockTSE'] : self::TSE_NONE;
- $staleTTL = isset( $opts['staleTTL'] ) ? $opts['staleTTL'] : self::STALE_TTL_NONE;
- $graceTTL = isset( $opts['graceTTL'] ) ? $opts['graceTTL'] : self::GRACE_TTL_NONE;
- $checkKeys = isset( $opts['checkKeys'] ) ? $opts['checkKeys'] : [];
- $busyValue = isset( $opts['busyValue'] ) ? $opts['busyValue'] : null;
- $popWindow = isset( $opts['hotTTR'] ) ? $opts['hotTTR'] : self::HOT_TTR;
- $ageNew = isset( $opts['ageNew'] ) ? $opts['ageNew'] : self::AGE_NEW;
- $minTime = isset( $opts['minAsOf'] ) ? $opts['minAsOf'] : self::MIN_TIMESTAMP_NONE;
+ $lowTTL = $opts['lowTTL'] ?? min( self::LOW_TTL, $ttl );
+ $lockTSE = $opts['lockTSE'] ?? self::TSE_NONE;
+ $staleTTL = $opts['staleTTL'] ?? self::STALE_TTL_NONE;
+ $graceTTL = $opts['graceTTL'] ?? self::GRACE_TTL_NONE;
+ $checkKeys = $opts['checkKeys'] ?? [];
+ $busyValue = $opts['busyValue'] ?? null;
+ $popWindow = $opts['hotTTR'] ?? self::HOT_TTR;
+ $ageNew = $opts['ageNew'] ?? self::AGE_NEW;
+ $minTime = $opts['minAsOf'] ?? self::MIN_TIMESTAMP_NONE;
$versioned = isset( $opts['version'] );
// Get a collection name to describe this class of key
ArrayIterator $keyedIds, $ttl, callable $callback, array $opts = []
) {
$valueKeys = array_keys( $keyedIds->getArrayCopy() );
- $checkKeys = isset( $opts['checkKeys'] ) ? $opts['checkKeys'] : [];
+ $checkKeys = $opts['checkKeys'] ?? [];
// Load required keys into process cache in one go
$this->warmupCache = $this->getRawKeysForWarmup(
) {
$idsByValueKey = $keyedIds->getArrayCopy();
$valueKeys = array_keys( $idsByValueKey );
- $checkKeys = isset( $opts['checkKeys'] ) ? $opts['checkKeys'] : [];
+ $checkKeys = $opts['checkKeys'] ?? [];
unset( $opts['lockTSE'] ); // incompatible
unset( $opts['busyValue'] ); // incompatible
return [ false, null ];
}
- $flags = isset( $wrapped[self::FLD_FLAGS] ) ? $wrapped[self::FLD_FLAGS] : 0;
+ $flags = $wrapped[self::FLD_FLAGS] ?? 0;
if ( ( $flags & self::FLG_STALE ) == self::FLG_STALE ) {
// Treat as expired, with the cache time as the expiration
$age = $now - $wrapped[self::FLD_TIME];
protected function determineKeyClass( $key ) {
$parts = explode( ':', $key );
- return isset( $parts[1] ) ? $parts[1] : $parts[0]; // sanity
+ return $parts[1] ?? $parts[0]; // sanity
}
/**
private function getNonProcessCachedKeys( array $keys, array $opts ) {
$keysFound = [];
if ( isset( $opts['pcTTL'] ) && $opts['pcTTL'] > 0 && $this->callbackDepth == 0 ) {
- $pcGroup = isset( $opts['pcGroup'] ) ? $opts['pcGroup'] : self::PC_PRIMARY;
+ $pcGroup = $opts['pcGroup'] ?? self::PC_PRIMARY;
$procCache = $this->getProcessCache( $pcGroup );
foreach ( $keys as $key ) {
if ( $procCache->get( $key ) !== false ) {
throw new UnexpectedValueException( "No channel specified." );
}
- $this->initialStartWindow = isset( $params['initialStartWindow'] )
- ? $params['initialStartWindow']
- : 3600;
- $this->logger = isset( $params['logger'] )
- ? $params['logger']
- : new NullLogger();
+ $this->initialStartWindow = $params['initialStartWindow'] ?? 3600;
+ $this->logger = $params['logger'] ?? new NullLogger();
}
public function setLogger( LoggerInterface $logger ) {
*/
protected function mergePositions( $curValue, array $shutdownPositions, &$cpIndex = null ) {
/** @var DBMasterPos[] $curPositions */
- $curPositions = isset( $curValue['positions'] ) ? $curValue['positions'] : [];
+ $curPositions = $curValue['positions'] ?? [];
// Use the newest positions for each DB master
foreach ( $shutdownPositions as $db => $pos ) {
if (
}
}
- $cpIndex = isset( $curValue['writeIndex'] ) ? $curValue['writeIndex'] : 0;
+ $cpIndex = $curValue['writeIndex'] ?? 0;
return [
'positions' => $curPositions,
$this->sessionVars = $params['variables'];
- $this->srvCache = isset( $params['srvCache'] )
- ? $params['srvCache']
- : new HashBagOStuff();
+ $this->srvCache = $params['srvCache'] ?? new HashBagOStuff();
$this->profiler = $params['profiler'];
$this->trxProfiler = $params['trxProfiler'];
* @since 1.18
*/
final public static function factory( $dbType, $p = [], $connect = self::NEW_CONNECTED ) {
- $class = self::getClass( $dbType, isset( $p['driver'] ) ? $p['driver'] : null );
+ $class = self::getClass( $dbType, $p['driver'] ?? null );
if ( class_exists( $class ) && is_subclass_of( $class, IDatabase::class ) ) {
// Resolve some defaults for b/c
- $p['host'] = isset( $p['host'] ) ? $p['host'] : false;
- $p['user'] = isset( $p['user'] ) ? $p['user'] : false;
- $p['password'] = isset( $p['password'] ) ? $p['password'] : false;
- $p['dbname'] = isset( $p['dbname'] ) ? $p['dbname'] : false;
- $p['flags'] = isset( $p['flags'] ) ? $p['flags'] : 0;
- $p['variables'] = isset( $p['variables'] ) ? $p['variables'] : [];
- $p['tablePrefix'] = isset( $p['tablePrefix'] ) ? $p['tablePrefix'] : '';
- $p['schema'] = isset( $p['schema'] ) ? $p['schema'] : '';
- $p['cliMode'] = isset( $p['cliMode'] )
- ? $p['cliMode']
- : ( PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg' );
- $p['agent'] = isset( $p['agent'] ) ? $p['agent'] : '';
+ $p['host'] = $p['host'] ?? false;
+ $p['user'] = $p['user'] ?? false;
+ $p['password'] = $p['password'] ?? false;
+ $p['dbname'] = $p['dbname'] ?? false;
+ $p['flags'] = $p['flags'] ?? 0;
+ $p['variables'] = $p['variables'] ?? [];
+ $p['tablePrefix'] = $p['tablePrefix'] ?? '';
+ $p['schema'] = $p['schema'] ?? '';
+ $p['cliMode'] = $p['cliMode'] ?? ( PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg' );
+ $p['agent'] = $p['agent'] ?? '';
if ( !isset( $p['connLogger'] ) ) {
$p['connLogger'] = new NullLogger();
}
if ( !isset( $p['queryLogger'] ) ) {
$p['queryLogger'] = new NullLogger();
}
- $p['profiler'] = isset( $p['profiler'] ) ? $p['profiler'] : null;
+ $p['profiler'] = $p['profiler'] ?? null;
if ( !isset( $p['trxProfiler'] ) ) {
$p['trxProfiler'] = new TransactionProfiler();
}
if ( isset( $options['LIMIT'] ) ) {
$sql = $this->limitResult( $sql, $options['LIMIT'],
- isset( $options['OFFSET'] ) ? $options['OFFSET'] : false );
+ $options['OFFSET'] ?? false );
}
$sql = "$sql $postLimitTail";
if ( !$var ) {
$column = null;
} elseif ( count( $var ) == 1 ) {
- $column = isset( $var[0] ) ? $var[0] : reset( $var );
+ $column = $var[0] ?? reset( $var );
} else {
throw new DBUnexpectedError( $this, __METHOD__ . ': got multiple columns.' );
}
* @return string
*/
protected function indexName( $index ) {
- return isset( $this->indexAliases[$index] )
- ? $this->indexAliases[$index]
- : $index;
+ return $this->indexAliases[$index] ?? $index;
}
public function addQuotes( $s ) {
// $conds. Then union them together (using UNION ALL, because the
// product *should* already be distinct).
$orderBy = $this->makeOrderBy( $options );
- $limit = isset( $options['LIMIT'] ) ? $options['LIMIT'] : null;
- $offset = isset( $options['OFFSET'] ) ? $options['OFFSET'] : false;
+ $limit = $options['LIMIT'] ?? null;
+ $offset = $options['OFFSET'] ?? false;
$all = empty( $options['NOTALL'] ) && !in_array( 'NOTALL', $options );
if ( !$this->unionSupportsOrderAndLimit() ) {
unset( $options['ORDER BY'], $options['LIMIT'], $options['OFFSET'] );
for ( $i = 0; $i < $length; ++$i ) {
$char = $encoded[$i];
if ( $char === '?' ) {
- $nextChar = isset( $encoded[$i + 1] ) ? $encoded[$i + 1] : null;
+ $nextChar = $encoded[$i + 1] ?? null;
if ( $nextChar === 'h' ) {
$decoded .= '-';
++$i;
$this->populateColumnCaches();
}
- return isset( $this->binaryColumnCache[$tableRaw] )
- ? $this->binaryColumnCache[$tableRaw]
- : [];
+ return $this->binaryColumnCache[$tableRaw] ?? [];
}
/**
$this->populateColumnCaches();
}
- return isset( $this->bitColumnCache[$tableRaw] )
- ? $this->bitColumnCache[$tableRaw]
- : [];
+ return $this->bitColumnCache[$tableRaw] ?? [];
}
private function populateColumnCaches() {
* @param array $params
*/
function __construct( array $params ) {
- $this->lagDetectionMethod = isset( $params['lagDetectionMethod'] )
- ? $params['lagDetectionMethod']
- : 'Seconds_Behind_Master';
- $this->lagDetectionOptions = isset( $params['lagDetectionOptions'] )
- ? $params['lagDetectionOptions']
- : [];
+ $this->lagDetectionMethod = $params['lagDetectionMethod'] ?? 'Seconds_Behind_Master';
+ $this->lagDetectionOptions = $params['lagDetectionOptions'] ?? [];
$this->useGTIDs = !empty( $params['useGTIDs' ] );
foreach ( [ 'KeyPath', 'CertPath', 'CAFile', 'CAPath', 'Ciphers' ] as $name ) {
$var = "ssl{$name}";
$this->$var = $params[$var];
}
}
- $this->sqlMode = isset( $params['sqlMode'] ) ? $params['sqlMode'] : '';
+ $this->sqlMode = $params['sqlMode'] ?? '';
$this->utf8Mode = !empty( $params['utf8Mode'] );
$this->insertSelectIsSafe = isset( $params['insertSelectIsSafe'] )
? (bool)$params['insertSelectIsSafe'] : null;
* - keywordTableMap : Map of reserved table names to alternative table names to use
*/
public function __construct( array $params ) {
- $this->port = isset( $params['port'] ) ? $params['port'] : false;
- $this->keywordTableMap = isset( $params['keywordTableMap'] )
- ? $params['keywordTableMap']
- : [];
+ $this->port = $params['port'] ?? false;
+ $this->keywordTableMap = $params['keywordTableMap'] ?? [];
parent::__construct( $params );
}
* @return string Value of $name or remapped name if $name is a reserved keyword
*/
public function remappedTableName( $name ) {
- return isset( $this->keywordTableMap[$name] ) ? $this->keywordTableMap[$name] : $name;
+ return $this->keywordTableMap[$name] ?? $name;
}
/**
}
$e = $this->conn->errorInfo();
- return isset( $e[2] ) ? $e[2] : '';
+ return $e[2] ?? '';
}
/**
$this->is_multiple = $info->multiple_key;
$this->is_key = ( $this->is_pk || $this->is_unique || $this->is_multiple );
$this->type = $info->type;
- $this->binary = isset( $info->binary ) ? $info->binary : false;
- $this->is_numeric = isset( $info->numeric ) ? $info->numeric : false;
- $this->is_blob = isset( $info->blob ) ? $info->blob : false;
- $this->is_unsigned = isset( $info->unsigned ) ? $info->unsigned : false;
- $this->is_zerofill = isset( $info->zerofill ) ? $info->zerofill : false;
+ $this->binary = $info->binary ?? false;
+ $this->is_numeric = $info->numeric ?? false;
+ $this->is_blob = $info->blob ?? false;
+ $this->is_unsigned = $info->unsigned ?? false;
+ $this->is_zerofill = $info->zerofill ?? false;
}
/**
$this->readOnlyReason = $conf['readOnlyReason'];
}
- $this->srvCache = isset( $conf['srvCache'] ) ? $conf['srvCache'] : new EmptyBagOStuff();
- $this->memStash = isset( $conf['memStash'] ) ? $conf['memStash'] : new EmptyBagOStuff();
- $this->wanCache = isset( $conf['wanCache'] )
- ? $conf['wanCache']
- : WANObjectCache::newEmpty();
+ $this->srvCache = $conf['srvCache'] ?? new EmptyBagOStuff();
+ $this->memStash = $conf['memStash'] ?? new EmptyBagOStuff();
+ $this->wanCache = $conf['wanCache'] ?? WANObjectCache::newEmpty();
foreach ( self::$loggerFields as $key ) {
- $this->$key = isset( $conf[$key] ) ? $conf[$key] : new \Psr\Log\NullLogger();
+ $this->$key = $conf[$key] ?? new \Psr\Log\NullLogger();
}
- $this->errorLogger = isset( $conf['errorLogger'] )
- ? $conf['errorLogger']
- : function ( Exception $e ) {
- trigger_error( get_class( $e ) . ': ' . $e->getMessage(), E_USER_WARNING );
- };
- $this->deprecationLogger = isset( $conf['deprecationLogger'] )
- ? $conf['deprecationLogger']
- : function ( $msg ) {
- trigger_error( $msg, E_USER_DEPRECATED );
- };
-
- $this->profiler = isset( $conf['profiler'] ) ? $conf['profiler'] : null;
- $this->trxProfiler = isset( $conf['trxProfiler'] )
- ? $conf['trxProfiler']
- : new TransactionProfiler();
+ $this->errorLogger = $conf['errorLogger'] ?? function ( Exception $e ) {
+ trigger_error( get_class( $e ) . ': ' . $e->getMessage(), E_USER_WARNING );
+ };
+ $this->deprecationLogger = $conf['deprecationLogger'] ?? function ( $msg ) {
+ trigger_error( $msg, E_USER_DEPRECATED );
+ };
+
+ $this->profiler = $conf['profiler'] ?? null;
+ $this->trxProfiler = $conf['trxProfiler'] ?? new TransactionProfiler();
$this->requestInfo = [
- 'IPAddress' => isset( $_SERVER[ 'REMOTE_ADDR' ] ) ? $_SERVER[ 'REMOTE_ADDR' ] : '',
- 'UserAgent' => isset( $_SERVER['HTTP_USER_AGENT'] ) ? $_SERVER['HTTP_USER_AGENT'] : '',
+ 'IPAddress' => $_SERVER[ 'REMOTE_ADDR' ] ?? '',
+ 'UserAgent' => $_SERVER['HTTP_USER_AGENT'] ?? '',
'ChronologyProtection' => 'true',
// phpcs:ignore MediaWiki.Usage.SuperGlobalsUsage.SuperGlobals -- library can't use $wgRequest
- 'ChronologyPositionIndex' => isset( $_GET['cpPosIndex'] ) ? $_GET['cpPosIndex'] : null
+ 'ChronologyPositionIndex' => $_GET['cpPosIndex'] ?? null
];
- $this->cliMode = isset( $conf['cliMode'] )
- ? $conf['cliMode']
- : ( PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg' );
- $this->hostname = isset( $conf['hostname'] ) ? $conf['hostname'] : gethostname();
- $this->agent = isset( $conf['agent'] ) ? $conf['agent'] : '';
+ $this->cliMode = $conf['cliMode'] ?? ( PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg' );
+ $this->hostname = $conf['hostname'] ?? gethostname();
+ $this->agent = $conf['agent'] ?? '';
$this->ticket = mt_rand();
}
public function __construct( array $conf ) {
parent::__construct( $conf );
- $this->servers = isset( $conf['servers'] ) ? $conf['servers'] : [];
+ $this->servers = $conf['servers'] ?? [];
foreach ( $this->servers as $i => $server ) {
if ( $i == 0 ) {
$this->servers[$i]['master'] = true;
}
}
- $this->externalClusters = isset( $conf['externalClusters'] )
- ? $conf['externalClusters']
- : [];
- $this->loadMonitorClass = isset( $conf['loadMonitorClass'] )
- ? $conf['loadMonitorClass']
- : 'LoadMonitor';
- $this->maxLag = isset( $conf['maxLag'] ) ? $conf['maxLag'] : self::MAX_LAG_DEFAULT;
+ $this->externalClusters = $conf['externalClusters'] ?? [];
+ $this->loadMonitorClass = $conf['loadMonitorClass'] ?? 'LoadMonitor';
+ $this->maxLag = $conf['maxLag'] ?? self::MAX_LAG_DEFAULT;
}
/**
: DatabaseDomain::newUnspecified();
$this->setLocalDomain( $localDomain );
- $this->waitTimeout = isset( $params['waitTimeout'] )
- ? $params['waitTimeout']
- : self::MAX_WAIT_DEFAULT;
+ $this->waitTimeout = $params['waitTimeout'] ?? self::MAX_WAIT_DEFAULT;
$this->readIndex = -1;
$this->conns = [
} else {
$this->wanCache = WANObjectCache::newEmpty();
}
- $this->profiler = isset( $params['profiler'] ) ? $params['profiler'] : null;
+ $this->profiler = $params['profiler'] ?? null;
if ( isset( $params['trxProfiler'] ) ) {
$this->trxProfiler = $params['trxProfiler'];
} else {
$this->trxProfiler = new TransactionProfiler();
}
- $this->errorLogger = isset( $params['errorLogger'] )
- ? $params['errorLogger']
- : function ( Exception $e ) {
- trigger_error( get_class( $e ) . ': ' . $e->getMessage(), E_USER_WARNING );
- };
- $this->deprecationLogger = isset( $params['deprecationLogger'] )
- ? $params['deprecationLogger']
- : function ( $msg ) {
- trigger_error( $msg, E_USER_DEPRECATED );
- };
+ $this->errorLogger = $params['errorLogger'] ?? function ( Exception $e ) {
+ trigger_error( get_class( $e ) . ': ' . $e->getMessage(), E_USER_WARNING );
+ };
+ $this->deprecationLogger = $params['deprecationLogger'] ?? function ( $msg ) {
+ trigger_error( $msg, E_USER_DEPRECATED );
+ };
foreach ( [ 'replLogger', 'connLogger', 'queryLogger', 'perfLogger' ] as $key ) {
- $this->$key = isset( $params[$key] ) ? $params[$key] : new NullLogger();
+ $this->$key = $params[$key] ?? new NullLogger();
}
- $this->host = isset( $params['hostname'] )
- ? $params['hostname']
- : ( gethostname() ?: 'unknown' );
- $this->cliMode = isset( $params['cliMode'] )
- ? $params['cliMode']
- : ( PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg' );
- $this->agent = isset( $params['agent'] ) ? $params['agent'] : '';
+ $this->host = $params['hostname'] ?? ( gethostname() ?: 'unknown' );
+ $this->cliMode = $params['cliMode'] ?? ( PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg' );
+ $this->agent = $params['agent'] ?? '';
if ( isset( $params['chronologyCallback'] ) ) {
$this->chronologyCallback = $params['chronologyCallback'];
foreach ( $lags as $i => $lag ) {
if ( $i != 0 ) {
# How much lag this server nominally is allowed to have
- $maxServerLag = isset( $this->servers[$i]['max lag'] )
- ? $this->servers[$i]['max lag']
- : $this->maxLag; // default
+ $maxServerLag = $this->servers[$i]['max lag'] ?? $this->maxLag; // default
# Constrain that futher by $maxLag argument
$maxServerLag = min( $maxServerLag, $maxLag );
public function getServerAttributes( $i ) {
return Database::attributesFromType(
$this->getServerType( $i ),
- isset( $this->servers[$i]['driver'] ) ? $this->servers[$i]['driver'] : null
+ $this->servers[$i]['driver'] ?? null
);
}
$server['agent'] = $this->agent;
// Use DBO_DEFAULT flags by default for LoadBalancer managed databases. Assume that the
// application calls LoadBalancer::commitMasterChanges() before the PHP script completes.
- $server['flags'] = isset( $server['flags'] ) ? $server['flags'] : IDatabase::DBO_DEFAULT;
+ $server['flags'] = $server['flags'] ?? IDatabase::DBO_DEFAULT;
// Create a live connection object
try {
}
public function getServerType( $i ) {
- return isset( $this->servers[$i]['type'] ) ? $this->servers[$i]['type'] : 'unknown';
+ return $this->servers[$i]['type'] ?? 'unknown';
}
public function getMasterPos() {
public function approveMasterChanges( array $options ) {
$this->assertTransactionRoundStage( self::ROUND_FINALIZED );
- $limit = isset( $options['maxWriteDuration'] ) ? $options['maxWriteDuration'] : 0;
+ $limit = $options['maxWriteDuration'] ?? 0;
$this->trxRoundStage = self::ROUND_ERROR; // "failed" until proven otherwise
$this->forEachOpenMasterConnection( function ( IDatabase $conn ) use ( $limit ) {
'load' => 1,
]
],
- 'trxProfiler' => isset( $params['trxProfiler'] ) ? $params['trxProfiler'] : null,
- 'srvCache' => isset( $params['srvCache'] ) ? $params['srvCache'] : null,
- 'wanCache' => isset( $params['wanCache'] ) ? $params['wanCache'] : null
+ 'trxProfiler' => $params['trxProfiler'] ?? null,
+ 'srvCache' => $params['srvCache'] ?? null,
+ 'wanCache' => $params['wanCache'] ?? null
] );
if ( isset( $params['readOnlyReason'] ) ) {
$this->wanCache = $wCache;
$this->replLogger = new NullLogger();
- $this->movingAveRatio = isset( $options['movingAveRatio'] )
- ? $options['movingAveRatio']
- : 0.1;
- $this->lagWarnThreshold = isset( $options['lagWarnThreshold'] )
- ? $options['lagWarnThreshold']
- : self::LAG_WARN_THRESHOLD;
+ $this->movingAveRatio = $options['movingAveRatio'] ?? 0.1;
+ $this->lagWarnThreshold = $options['lagWarnThreshold'] ?? self::LAG_WARN_THRESHOLD;
}
public function setLogger( LoggerInterface $logger ) {
$close = true; // new connection
}
- $lastWeight = isset( $staleValue['weightScales'][$i] )
- ? $staleValue['weightScales'][$i]
- : 1.0;
+ $lastWeight = $staleValue['weightScales'][$i] ?? 1.0;
$coefficient = $this->getWeightScale( $i, $conn ?: null );
$newWeight = $movAveRatio * $coefficient + ( 1 - $movAveRatio ) * $lastWeight;
) {
parent::__construct( $lb, $srvCache, $wCache, $options );
- $this->warmCacheRatio = isset( $options['warmCacheRatio'] )
- ? $options['warmCacheRatio']
- : 0.0;
+ $this->warmCacheRatio = $options['warmCacheRatio'] ?? 0.0;
}
protected function getWeightScale( $index, IDatabase $conn = null ) {
__CLASS__ . ' requires a Redis client library. ' .
'See https://www.mediawiki.org/wiki/Redis#Setup' );
}
- $this->logger = isset( $options['logger'] )
- ? $options['logger']
- : new \Psr\Log\NullLogger();
+ $this->logger = $options['logger'] ?? new \Psr\Log\NullLogger();
$this->connectTimeout = $options['connectTimeout'];
$this->readTimeout = $options['readTimeout'];
$this->persistent = $options['persistent'];
* @return string The name of the service behind this VRS object.
*/
public function getName() {
- return isset( $this->params['name'] ) ? $this->params['name'] : static::class;
+ return $this->params['name'] ?? static::class;
}
/**
list( $ns, $tag ) = explode( ' ', $elm, 2 );
if ( isset( $this->items[$ns][$tag]['validate'] ) ) {
$info =& $this->items[$ns][$tag];
- $finalName = isset( $info['map_name'] )
- ? $info['map_name'] : $tag;
+ $finalName = $info['map_name'] ?? $tag;
if ( is_array( $info['validate'] ) ) {
$validate = $info['validate'];
private function endElementModeLi( $elm ) {
list( $ns, $tag ) = explode( ' ', $this->curItem[0], 2 );
$info = $this->items[$ns][$tag];
- $finalName = isset( $info['map_name'] )
- ? $info['map_name'] : $tag;
+ $finalName = $info['map_name'] ?? $tag;
array_shift( $this->mode );
array_unshift( $this->mode, $mode );
array_unshift( $this->curItem, $ns . ' ' . $tag );
if ( $mode === self::MODE_STRUCT ) {
- $this->ancestorStruct = isset( $this->items[$ns][$tag]['map_name'] )
- ? $this->items[$ns][$tag]['map_name'] : $tag;
+ $this->ancestorStruct = $this->items[$ns][$tag]['map_name'] ?? $tag;
}
if ( $this->charContent !== false ) {
// Something weird.
throw new RuntimeException( 'Can not find parent of BAGSTRUCT.' );
}
list( $curNS, $curTag ) = explode( ' ', $this->curItem[1] );
- $this->ancestorStruct = isset( $this->items[$curNS][$curTag]['map_name'] )
- ? $this->items[$curNS][$curTag]['map_name'] : $curTag;
+ $this->ancestorStruct = $this->items[$curNS][$curTag]['map_name'] ?? $curTag;
$this->doAttribs( $attribs );
} else {
*/
private function saveValue( $ns, $tag, $val ) {
$info =& $this->items[$ns][$tag];
- $finalName = isset( $info['map_name'] )
- ? $info['map_name'] : $tag;
+ $finalName = $info['map_name'] ?? $tag;
if ( isset( $info['validate'] ) ) {
if ( is_array( $info['validate'] ) ) {
$validate = $info['validate'];
// new key (5::duration/6::flags) or old key (0/optional 1)
if ( $entry->isLegacy() ) {
$rawDuration = $parameters[0];
- $rawFlags = isset( $parameters[1] ) ? $parameters[1] : '';
+ $rawFlags = $parameters[1] ?? '';
} else {
$rawDuration = $parameters['5::duration'];
$rawFlags = $parameters['6::flags'];
if ( count( $oldGroups ) ) {
$params[3] = [ 'raw' => $this->formatRightsList( $oldGroups,
- isset( $allParams['oldmetadata'] ) ? $allParams['oldmetadata'] : [] ) ];
+ $allParams['oldmetadata'] ?? [] ) ];
} else {
$params[3] = $this->msg( 'rightsnone' )->text();
}
// Array_values is used here because of T44211
// see use of array_unique in UserrightsPage::doSaveUserGroups on $newGroups.
$params[4] = [ 'raw' => $this->formatRightsList( array_values( $newGroups ),
- isset( $allParams['newmetadata'] ) ? $allParams['newmetadata'] : [] ) ];
+ $allParams['newmetadata'] ?? [] ) ];
} else {
$params[4] = $this->msg( 'rightsnone' )->text();
}
if ( isset( $oldmetadata[$index] ) ) {
$result += $oldmetadata[$index];
}
- $result['expiry'] = ApiResult::formatExpiry( isset( $result['expiry'] ) ?
- $result['expiry'] : null );
+ $result['expiry'] = ApiResult::formatExpiry( $result['expiry'] ?? null );
return $result;
}, array_keys( $params['4:array:oldgroups'] ) );
if ( isset( $newmetadata[$index] ) ) {
$result += $newmetadata[$index];
}
- $result['expiry'] = ApiResult::formatExpiry( isset( $result['expiry'] ) ?
- $result['expiry'] : null );
+ $result['expiry'] = ApiResult::formatExpiry( $result['expiry'] ?? null );
return $result;
}, array_keys( $params['5:array:newgroups'] ) );
global $wgSMTP, $wgEnotifMaxRecips, $wgAdditionalMailParams;
$mime = null;
- $replyto = isset( $options['replyTo'] ) ? $options['replyTo'] : null;
- $contentType = isset( $options['contentType'] ) ?
- $options['contentType'] : 'text/plain; charset=UTF-8';
- $headers = isset( $options['headers'] ) ? $options['headers'] : [];
+ $replyto = $options['replyTo'] ?? null;
+ $contentType = $options['contentType'] ?? 'text/plain; charset=UTF-8';
+ $headers = $options['headers'] ?? [];
// Allow transformation of content, such as encrypting/signing
$error = false;
}
}
- $meta->getExif( $filename, isset( $seg['byteOrder'] ) ? $seg['byteOrder'] : 'BE' );
+ $meta->getExif( $filename, $seg['byteOrder'] ?? 'BE' );
return $meta->getMetadataArray();
}
* @return bool|string
*/
public function makeParamString( $params ) {
- $page = isset( $params['page'] ) ? $params['page'] : 1;
+ $page = $params['page'] ?? 1;
if ( !isset( $params['width'] ) ) {
return false;
}
throw new MWException( __METHOD__ . ' called in the old style' );
}
- $alt = isset( $options['alt'] ) ? $options['alt'] : '';
+ $alt = $options['alt'] ?? '';
- $query = isset( $options['desc-query'] ) ? $options['desc-query'] : '';
+ $query = $options['desc-query'] ?? '';
$attribs = [
'alt' => $alt,
class TransformParameterError extends MediaTransformError {
function __construct( $params ) {
parent::__construct( 'thumbnail_error',
- max( isset( $params['width'] ) ? $params['width'] : 0, 120 ),
- max( isset( $params['height'] ) ? $params['height'] : 0, 120 ),
+ max( $params['width'] ?? 0, 120 ),
+ max( $params['height'] ?? 0, 120 ),
wfMessage( 'thumbnail_invalid_params' )
);
}
);
parent::__construct( 'thumbnail_error',
- max( isset( $params['width'] ) ? $params['width'] : 0, 120 ),
- max( isset( $params['height'] ) ? $params['height'] : 0, 120 ),
+ max( $params['width'] ?? 0, 120 ),
+ max( $params['height'] ?? 0, 120 ),
$msg
);
}
$clientHeight = $params['height'];
$physicalWidth = $params['physicalWidth'];
$physicalHeight = $params['physicalHeight'];
- $lang = isset( $params['lang'] ) ? $params['lang'] : $this->getDefaultRenderLanguage( $image );
+ $lang = $params['lang'] ?? $this->getDefaultRenderLanguage( $image );
if ( $flags & self::TRANSFORM_LATER ) {
return new ThumbnailImage( $image, $dstUrl, $dstPath, $params );
'mimeType' => $image->getMimeType(),
'dstPath' => $dstPath,
'dstUrl' => $dstUrl,
- 'interlace' => isset( $params['interlace'] ) ? $params['interlace'] : false,
+ 'interlace' => $params['interlace'] ?? false,
];
if ( isset( $params['quality'] ) && $params['quality'] === 'low' ) {
} elseif ( isset( $params['class'] ) ) {
$class = $params['class'];
// Automatically set the 'async' update handler
- $params['asyncHandler'] = isset( $params['asyncHandler'] )
- ? $params['asyncHandler']
- : 'DeferredUpdates::addCallableUpdate';
+ $params['asyncHandler'] = $params['asyncHandler'] ?? 'DeferredUpdates::addCallableUpdate';
// Enable reportDupes by default
- $params['reportDupes'] = isset( $params['reportDupes'] )
- ? $params['reportDupes']
- : true;
+ $params['reportDupes'] = $params['reportDupes'] ?? true;
// Do b/c logic for SqlBagOStuff
if ( is_a( $class, SqlBagOStuff::class, true ) ) {
if ( isset( $params['server'] ) && !isset( $params['servers'] ) ) {
$cache = MediaWikiServices::getInstance()->getLocalServerObjectCache();
if ( $cache instanceof EmptyBagOStuff ) {
if ( is_array( $fallback ) ) {
- $fallback = isset( $fallback['fallback'] ) ? $fallback['fallback'] : CACHE_NONE;
+ $fallback = $fallback['fallback'] ?? CACHE_NONE;
}
$cache = self::getInstance( $fallback );
}
if ( is_string( $tag ) ) {
$this->serverTags[$index] = $tag;
} else {
- $this->serverTags[$index] = isset( $info['host'] ) ? $info['host'] : "#$index";
+ $this->serverTags[$index] = $info['host'] ?? "#$index";
}
++$index;
}
if ( $this->serverInfos ) {
// Use custom database defined by server connection info
$info = $this->serverInfos[$serverIndex];
- $type = isset( $info['type'] ) ? $info['type'] : 'mysql';
- $host = isset( $info['host'] ) ? $info['host'] : '[unknown]';
+ $type = $info['type'] ?? 'mysql';
+ $host = $info['host'] ?? '[unknown]';
$this->logger->debug( __CLASS__ . ": connecting to $host" );
// Use a blank trx profiler to ignore expections as this is a cache
$info['trxProfiler'] = new TransactionProfiler();
$option = 0;
}
- return isset( $wgImageLimits[$option] )
- ? $wgImageLimits[$option]
- : [ 800, 600 ]; // if nothing is set, fallback to a hardcoded default
+ // if nothing is set, fallback to a hardcoded default
+ return $wgImageLimits[$option] ?? [ 800, 600 ];
}
/**
}
// raise error, when the edit is an edit without a new version
- $statusRev = isset( $status->value['revision'] )
- ? $status->value['revision']
- : null;
+ $statusRev = $status->value['revision'] ?? null;
if ( !( $statusRev instanceof Revision ) ) {
$resultDetails = [ 'current' => $current ];
return [ [ 'alreadyrolled',
$info = $this->getQueryInfo();
$tables = $info['tables'];
$fields = $info['fields'];
- $conds = isset( $info['conds'] ) ? $info['conds'] : [];
- $options = isset( $info['options'] ) ? $info['options'] : [];
- $join_conds = isset( $info['join_conds'] ) ? $info['join_conds'] : [];
+ $conds = $info['conds'] ?? [];
+ $options = $info['options'] ?? [];
+ $join_conds = $info['join_conds'] ?? [];
$sortColumns = array_merge( [ $this->mIndexField ], $this->mExtraSortFields );
if ( $descending ) {
$options['ORDER BY'] = $sortColumns;
$fieldNames = $this->getFieldNames();
foreach ( $fieldNames as $field => $name ) {
- $value = isset( $row->$field ) ? $row->$field : null;
+ $value = $row->$field ?? null;
$formatted = strval( $this->formatValue( $field, $value ) );
if ( $formatted == '' ) {
$name = trim( $frame->expand( $bits['name'], PPFrame::STRIP_COMMENTS ) );
$value = trim( $frame->expand( $bits['value'] ) );
if ( preg_match( '/^(?:["\'](.+)["\']|""|\'\')$/s', $value, $m ) ) {
- $value = isset( $m[1] ) ? $m[1] : '';
+ $value = $m[1] ?? '';
}
$attributes[$name] = $value;
}
foreach ( $entries as $index => $entry ) {
$pdbk = $entry['pdbk'];
$title = $entry['title'];
- $query = isset( $entry['query'] ) ? $entry['query'] : [];
+ $query = $entry['query'] ?? [];
$key = "$ns:$index";
$searchkey = "<!--LINK'\" $key-->";
$displayText = $entry['text'];
if ( is_string( $stuff['text'] ) ) {
$text = strtr( $text, "\x7f", "?" );
}
- $finalTitle = isset( $stuff['finalTitle'] ) ? $stuff['finalTitle'] : $title;
+ $finalTitle = $stuff['finalTitle'] ?? $title;
if ( isset( $stuff['deps'] ) ) {
foreach ( $stuff['deps'] as $dep ) {
$this->mOutput->addTemplate( $dep['title'], $dep['page_id'], $dep['rev_id'] );
if ( preg_match( '/[<>\r\n]/', $tag, $m ) ) {
throw new MWException( "Invalid character {$m[0]} in setHook('$tag', ...) call" );
}
- $oldVal = isset( $this->mTagHooks[$tag] ) ? $this->mTagHooks[$tag] : null;
+ $oldVal = $this->mTagHooks[$tag] ?? null;
$this->mTagHooks[$tag] = $callback;
if ( !in_array( $tag, $this->mStripList ) ) {
$this->mStripList[] = $tag;
if ( preg_match( '/[<>\r\n]/', $tag, $m ) ) {
throw new MWException( "Invalid character {$m[0]} in setTransparentHook('$tag', ...) call" );
}
- $oldVal = isset( $this->mTransparentTagHooks[$tag] ) ? $this->mTransparentTagHooks[$tag] : null;
+ $oldVal = $this->mTransparentTagHooks[$tag] ?? null;
$this->mTransparentTagHooks[$tag] = $callback;
return $oldVal;
if ( preg_match( '/[<>\r\n]/', $tag, $m ) ) {
throw new MWException( "Invalid character {$m[0]} in setFunctionTagHook('$tag', ...) call" );
}
- $old = isset( $this->mFunctionTagHooks[$tag] ) ?
- $this->mFunctionTagHooks[$tag] : null;
+ $old = $this->mFunctionTagHooks[$tag] ?? null;
$this->mFunctionTagHooks[$tag] = [ $callback, $flags ];
if ( !in_array( $tag, $this->mStripList ) ) {
Hooks::run( 'ParserMakeImageParams', [ $title, $file, &$params, $this ] );
# Linker does the rest
- $time = isset( $options['time'] ) ? $options['time'] : false;
+ $time = $options['time'] ?? false;
$ret = Linker::makeImageLink( $this, $title, $file, $params['frame'], $params['handler'],
$time, $descQuery, $this->mOptions->getThumbSize() );
* @note You need to use getProperties() to check for boolean and null properties.
*/
public function getProperty( $name ) {
- return isset( $this->mProperties[$name] ) ? $this->mProperties[$name] : false;
+ return $this->mProperties[$name] ?? false;
}
public function unsetProperty( $name ) {
if ( $level === false ) {
return $this->title->getPrefixedDBkey();
} else {
- return isset( $this->titleCache[$level] ) ? $this->titleCache[$level] : false;
+ return $this->titleCache[$level] ?? false;
}
}
if ( $level === false ) {
return $this->title->getPrefixedDBkey();
} else {
- return isset( $this->titleCache[$level] ) ? $this->titleCache[$level] : false;
+ return $this->titleCache[$level] ?? false;
}
}
*/
static function attributeWhitelist( $element ) {
$list = self::setupAttributeWhitelist();
- return isset( $list[$element] )
- ? $list[$element]
- : [];
+ return $list[$element] ?? [];
}
/**
}
protected function shouldUseHashExtension() {
- return isset( $this->config['use-hash-extension'] ) ?
- $this->config['use-hash-extension'] : function_exists( 'hash_pbkdf2' );
+ return $this->config['use-hash-extension'] ?? function_exists( 'hash_pbkdf2' );
}
public function crypt( $password ) {
PoolCounter::QUEUE_FULL => 'pool-queuefull',
PoolCounter::TIMEOUT => 'pool-timeout' ];
- $status = Status::newFatal( isset( $errors[$status->value] )
- ? $errors[$status->value]
- : 'pool-errorunknown' );
+ $status = Status::newFatal( $errors[$status->value] ?? 'pool-errorunknown' );
$this->logError( $status );
return $this->error( $status );
}
$info['disabled'] = 'disabled';
}
$field = HTMLForm::loadInputFromParameters( $name, $info, $dummyForm ); // For validation
- $globalDefault = isset( $defaultOptions[$name] )
- ? $defaultOptions[$name]
- : null;
+ $globalDefault = $defaultOptions[$name] ?? null;
// If it validates, set it as the default
if ( isset( $info['default'] ) ) {
if ( ( isset( $info['type'] ) && $info['type'] == 'multiselect' ) ||
( isset( $info['class'] ) && $info['class'] == \HTMLMultiSelectField::class ) ) {
$options = HTMLFormField::flattenOptions( $info['options'] );
- $prefix = isset( $info['prefix'] ) ? $info['prefix'] : $name;
+ $prefix = $info['prefix'] ?? $name;
$val = [];
foreach ( $options as $value ) {
( isset( $info['class'] ) && $info['class'] == \HTMLCheckMatrix::class ) ) {
$columns = HTMLFormField::flattenOptions( $info['columns'] );
$rows = HTMLFormField::flattenOptions( $info['rows'] );
- $prefix = isset( $info['prefix'] ) ? $info['prefix'] : $name;
+ $prefix = $info['prefix'] ?? $name;
$val = [];
foreach ( $columns as $column ) {
public function __construct( array $params = [] ) {
parent::__construct( $params );
- $flags = isset( $params['flags'] ) ? $params['flags'] : 0;
+ $flags = $params['flags'] ?? 0;
$options = isset( $params['exclude'] )
? [ 'ignored_functions' => $params['exclude'] ] : [];
Xhprof::enable( $flags, $options );
* @param array $stats
*/
public function log( array $stats ) {
- $prefix = isset( $this->params['prefix'] ) ? $this->params['prefix'] : '';
+ $prefix = $this->params['prefix'] ?? '';
$contextStats = MediaWikiServices::getInstance()->getStatsdDataFactory();
foreach ( $stats as $stat ) {
function __construct( Profiler $collector, array $params ) {
parent::__construct( $collector, $params );
- $this->thresholdMs = isset( $params['thresholdMs'] )
- ? $params['thresholdMs']
- : 1.0;
+ $this->thresholdMs = $params['thresholdMs'] ?? 1.0;
}
public function log( array $stats ) {
if ( $this->collector->getTemplated() ) {
if ( wfIsCLI() ) {
print "<!--\n{$out}\n-->\n";
} elseif ( $contentType === 'text/html' ) {
- $visible = isset( $this->params['visible'] ) ?
- $this->params['visible'] : false;
+ $visible = $this->params['visible'] ?? false;
if ( $visible ) {
print "<pre>{$out}</pre>";
} else {
}
public function getRequirements( array $info ) {
- return isset( $info['requires'] ) ? $info['requires'] : [];
+ return $info['requires'] ?? [];
}
protected function extractHooks( array $info ) {
}
protected function extractResourceLoaderModules( $dir, array $info ) {
- $defaultPaths = isset( $info['ResourceFileModulePaths'] )
- ? $info['ResourceFileModulePaths']
- : false;
+ $defaultPaths = $info['ResourceFileModulePaths'] ?? false;
if ( isset( $defaultPaths['localBasePath'] ) ) {
if ( $defaultPaths['localBasePath'] === '' ) {
// Avoid double slashes (e.g. /extensions/Example//path)
protected function extractCredits( $path, array $info ) {
$credits = [
'path' => $path,
- 'type' => isset( $info['type'] ) ? $info['type'] : 'other',
+ 'type' => $info['type'] ?? 'other',
];
foreach ( self::$creditsAttributes as $attr ) {
if ( isset( $info[$attr] ) ) {
$strContent = isset( $styles['css'] ) ? implode( '', $styles['css'] ) : '';
break;
default:
- $scripts = isset( $content['scripts'] ) ? $content['scripts'] : '';
+ $scripts = $content['scripts'] ?? '';
if ( is_string( $scripts ) ) {
if ( $name === 'site' || $name === 'user' ) {
// Legacy scripts that run in the global scope without a closure.
$strContent = self::makeLoaderImplementScript(
$implementKey,
$scripts,
- isset( $content['styles'] ) ? $content['styles'] : [],
+ $content['styles'] ?? [],
isset( $content['messagesBlob'] ) ? new XmlJsCode( $content['messagesBlob'] ) : [],
- isset( $content['templates'] ) ? $content['templates'] : []
+ $content['templates'] ?? []
);
break;
}
$collatedFiles[$default][] = $value;
} elseif ( is_array( $value ) ) {
// File name as the key, options array as the value
- $optionValue = isset( $value[$option] ) ? $value[$option] : $default;
+ $optionValue = $value[$option] ?? $default;
if ( !isset( $collatedFiles[$optionValue] ) ) {
$collatedFiles[$optionValue] = [];
}
public function getImage( $name, ResourceLoaderContext $context ) {
$this->loadFromDefinition();
$images = $this->getImages( $context );
- return isset( $images[$name] ) ? $images[$name] : null;
+ return $images[$name] ?? null;
}
/**
if ( !isset( $this->imageObjects[$skin] ) ) {
$this->imageObjects[$skin] = [];
if ( !isset( $this->images[$skin] ) ) {
- $this->images[$skin] = isset( $this->images['default'] ) ?
- $this->images['default'] :
- [];
+ $this->images[$skin] = $this->images['default'] ?? [];
}
foreach ( $this->images[$skin] as $name => $options ) {
$fileDescriptor = is_string( $options ) ? $options : $options['file'];
if ( !isset( $this->globalVariants[$skin] ) ) {
$this->globalVariants[$skin] = [];
if ( !isset( $this->variants[$skin] ) ) {
- $this->variants[$skin] = isset( $this->variants['default'] ) ?
- $this->variants['default'] :
- [];
+ $this->variants[$skin] = $this->variants['default'] ?? [];
}
foreach ( $this->variants[$skin] as $name => $config ) {
if ( isset( $config['global'] ) && $config['global'] ) {
$themes = self::getSkinThemeMap();
// For backwards-compatibility, allow missing 'themeImages'
- $module = isset( $this->definition['themeImages'] ) ? $this->definition['themeImages'] : '';
+ $module = $this->definition['themeImages'] ?? '';
$definition = [];
foreach ( $themes as $skin => $theme ) {
if ( $options['type'] !== 'style' ) {
continue;
}
- $media = isset( $options['media'] ) ? $options['media'] : 'all';
+ $media = $options['media'] ?? 'all';
$style = $this->getContent( $titleText, $context );
if ( strval( $style ) === '' ) {
continue;
$bitPars = $params['value'];
$comment = $params['comment'];
- $perItemStatus = isset( $params['perItemStatus'] ) ? $params['perItemStatus'] : false;
+ $perItemStatus = $params['perItemStatus'] ?? false;
// CAS-style checks are done on the _deleted fields so the select
// does not need to use FOR UPDATE nor be in the atomic section
'oldBits' => $virtualOldBits,
'comment' => $comment,
'ids' => $idsForLog,
- 'tags' => isset( $params['tags'] ) ? $params['tags'] : [],
+ 'tags' => $params['tags'] ?? [],
] + $authorFields
);
throw new NoSuchServiceException( $name );
}
- return isset( $this->services[$name] ) ? $this->services[$name] : null;
+ return $this->services[$name] ?? null;
}
/**
);
}
- $prefix = isset( $this->sessionCookieOptions['prefix'] )
- ? $this->sessionCookieOptions['prefix']
- : $this->config->get( 'CookiePrefix' );
+ $prefix = $this->sessionCookieOptions['prefix'] ?? $this->config->get( 'CookiePrefix' );
$id = $request->getCookie( $this->sessionCookieName, $prefix );
return SessionManager::validateSessionId( $id ) ? $id : null;
}
return [];
}
- $prefix = isset( $this->sessionCookieOptions['prefix'] )
- ? $this->sessionCookieOptions['prefix']
- : $this->config->get( 'CookiePrefix' );
+ $prefix = $this->sessionCookieOptions['prefix'] ?? $this->config->get( 'CookiePrefix' );
return [ $prefix . $this->sessionCookieName ];
}
// Now merge the data into the Session object.
$changed = false;
- $cache = isset( $this->sessionFieldCache[$id] ) ? $this->sessionFieldCache[$id] : [];
+ $cache = $this->sessionFieldCache[$id] ?? [];
foreach ( $data as $key => $value ) {
if ( !array_key_exists( $key, $cache ) ) {
if ( $session->exists( $key ) ) {
*/
public function getProvider( $name ) {
$providers = $this->getProviders();
- return isset( $providers[$name] ) ? $providers[$name] : null;
+ return $providers[$name] ?? null;
}
/**
$splitCommand = explode( ' ', $command, 2 );
$this->logger->debug(
"firejail: Command {$splitCommand[0]} {params} has no restrictions",
- [ 'params' => isset( $splitCommand[1] ) ? $splitCommand[1] : '' ]
+ [ 'params' => $splitCommand[1] ?? '' ]
);
return parent::buildFinalCommand( $command );
}
if ( isset( $item['text'] ) ) {
$text = $item['text'];
} else {
- $text = wfMessage( isset( $item['msg'] ) ? $item['msg'] : $key )->text();
+ $text = wfMessage( $item['msg'] ?? $key )->text();
}
$html = htmlspecialchars( $text );
}
while ( count( $wrapper ) > 0 ) {
$element = array_pop( $wrapper );
- $html = Html::rawElement( $element['tag'], isset( $element['attributes'] )
- ? $element['attributes']
- : null, $html );
+ $html = Html::rawElement( $element['tag'], $element['attributes'] ?? null, $html );
}
}
if ( isset( $item['itemtitle'] ) ) {
$attrs['title'] = $item['itemtitle'];
}
- return Html::rawElement( isset( $options['tag'] ) ? $options['tag'] : 'li', $attrs, $html );
+ return Html::rawElement( $options['tag'] ?? 'li', $attrs, $html );
}
function makeSearchInput( $attrs = [] ) {
unset( $buttonAttrs['height'] );
$imgAttrs = [
'src' => $attrs['src'],
- 'alt' => isset( $attrs['alt'] )
- ? $attrs['alt']
- : wfMessage( 'searchbutton' )->text(),
- 'width' => isset( $attrs['width'] ) ? $attrs['width'] : null,
- 'height' => isset( $attrs['height'] ) ? $attrs['height'] : null,
+ 'alt' => $attrs['alt'] ?? wfMessage( 'searchbutton' )->text(),
+ 'width' => $attrs['width'] ?? null,
+ 'height' => $attrs['height'] ?? null,
];
return Html::rawElement( 'button', $buttonAttrs, Html::element( 'img', $imgAttrs ) );
default:
if ( is_string( $icon ) ) {
$html = $icon;
} else { // Assuming array
- $url = isset( $icon["url"] ) ? $icon["url"] : null;
+ $url = $icon["url"] ?? null;
unset( $icon["url"] );
if ( isset( $icon["src"] ) && $withImage === 'withImage' ) {
// do this the lazy way, just pass icon data as an attribute array
if ( count( $newtalks ) == 1 && $newtalks[0]['wiki'] === wfWikiID() ) {
$uTalkTitle = $user->getTalkPage();
- $lastSeenRev = isset( $newtalks[0]['rev'] ) ? $newtalks[0]['rev'] : null;
+ $lastSeenRev = $newtalks[0]['rev'] ?? null;
$nofAuthors = 0;
if ( $lastSeenRev !== null ) {
$plural = true; // Default if we have a last seen revision: if unknown, use plural
* @return ChangesListFilterGroup|null Group, or null if not registered
*/
public function getFilterGroup( $groupName ) {
- return isset( $this->filterGroups[$groupName] ) ?
- $this->filterGroups[$groupName] :
- null;
+ return $this->filterGroups[$groupName] ?? null;
}
// Currently, this intentionally only includes filters that display
unset( $legendItems['unpatrolled'] );
}
foreach ( $legendItems as $key => $item ) { # generate items of the legend
- $label = isset( $item['legend'] ) ? $item['legend'] : $item['title'];
+ $label = $item['legend'] ?? $item['title'];
$letter = $item['letter'];
- $cssClass = isset( $item['class'] ) ? $item['class'] : $key;
+ $cssClass = $item['class'] ?? $key;
$legend .= Html::element( 'dt',
[ 'class' => $cssClass ], $context->msg( $letter )->text()
$i = 0;
foreach ( $res as $row ) {
$i++;
- $namespace = isset( $row->namespace ) ? $row->namespace : NS_FILE;
+ $namespace = $row->namespace ?? NS_FILE;
$title = Title::makeTitleSafe( $namespace, $row->title );
if ( $title instanceof Title && $title->getNamespace() == NS_FILE ) {
$gallery->add( $title, $this->getCellHtml( $row ) );
// keep the ordering from getCoreFieldDescriptors() where there is no explicit weight
foreach ( $coreFieldDescriptors as $fieldName => $coreField ) {
- $requestField = isset( $formDescriptor[$fieldName] ) ?
- $formDescriptor[$fieldName] : [];
+ $requestField = $formDescriptor[$fieldName] ?? [];
// remove everything that is not in the fieldinfo, is not marked as a supplemental field
// to something in the fieldinfo, is not B/C for the pre-AuthManager templates,
}
$title = Title::makeTitle( intval( $row->namespace ), $row->title );
if ( $title ) {
- $date = isset( $row->timestamp ) ? $row->timestamp : '';
+ $date = $row->timestamp ?? '';
$comments = '';
if ( $title ) {
$talkpage = $title->getTalkPage();
}
function feedItemAuthor( $row ) {
- return isset( $row->user_text ) ? $row->user_text : '';
+ return $row->user_text ?? '';
}
function feedTitle() {
$linkRenderer = $this->getLinkRenderer();
foreach ( $allGroups as $group ) {
- $permissions = isset( $groupPermissions[$group] )
- ? $groupPermissions[$group]
- : [];
+ $permissions = $groupPermissions[$group] ?? [];
$groupname = ( $group == '*' ) // Replace * with a more descriptive groupname
? 'all'
: $group;
$grouplink = '';
}
- $revoke = isset( $revokePermissions[$group] ) ? $revokePermissions[$group] : [];
- $addgroups = isset( $addGroups[$group] ) ? $addGroups[$group] : [];
- $removegroups = isset( $removeGroups[$group] ) ? $removeGroups[$group] : [];
- $addgroupsSelf = isset( $groupsAddToSelf[$group] ) ? $groupsAddToSelf[$group] : [];
- $removegroupsSelf = isset( $groupsRemoveFromSelf[$group] )
- ? $groupsRemoveFromSelf[$group]
- : [];
+ $revoke = $revokePermissions[$group] ?? [];
+ $addgroups = $addGroups[$group] ?? [];
+ $removegroups = $removeGroups[$group] ?? [];
+ $addgroupsSelf = $groupsAddToSelf[$group] ?? [];
+ $removegroupsSelf = $groupsRemoveFromSelf[$group] ?? [];
$id = $group == '*' ? false : Sanitizer::escapeIdForAttribute( $group );
$out->addHTML( Html::rawElement( 'tr', [ 'id' => $id ], "
$this->totalCount = $this->totalBytes = 0;
foreach ( $res as $row ) {
$mediaStats = $this->splitFakeTitle( $row->title );
- $this->totalCount += isset( $mediaStats[2] ) ? $mediaStats[2] : 0;
- $this->totalBytes += isset( $mediaStats[3] ) ? $mediaStats[3] : 0;
+ $this->totalCount += $mediaStats[2] ?? 0;
+ $this->totalBytes += $mediaStats[3] ?? 0;
}
$res->seek( 0 );
}
}
protected function feedItemAuthor( $row ) {
- return isset( $row->rc_user_text ) ? $row->rc_user_text : '';
+ return $row->rc_user_text ?? '';
}
protected function feedItemDesc( $row ) {
* @return Status
*/
public function onSubmit( array $data ) {
- $username = isset( $data['Username'] ) ? $data['Username'] : null;
- $email = isset( $data['Email'] ) ? $data['Email'] : null;
+ $username = $data['Username'] ?? null;
+ $email = $data['Email'] ?? null;
$this->method = $username ? 'username' : 'email';
$this->result = Status::wrap(
}
if ( $add ) {
foreach ( $add as $index => $group ) {
- $expiry = isset( $groupExpiries[$group] ) ? $groupExpiries[$group] : null;
+ $expiry = $groupExpiries[$group] ?? null;
if ( !$user->addGroup( $group, $expiry ) ) {
unset( $add[$index] );
}
public static function getExtensionTypeName( $type ) {
$types = self::getExtensionTypes();
- return isset( $types[$type] ) ? $types[$type] : $types['other'];
+ return $types[$type] ?? $types['other'];
}
/**
$description = $out->parseInline( $description );
// ... now get the authors for this extension
- $authors = isset( $extension['author'] ) ? $extension['author'] : [];
+ $authors = $extension['author'] ?? [];
$authors = $this->listAuthors( $authors, $extension['name'], $extensionPath );
// Finally! Create the table
} else {
$plink = $this->getLinkRenderer()->makeLink( $nt, $text );
- $currentValue = isset( $this->currentCategoryCounts[$result->title] )
- ? $this->currentCategoryCounts[$result->title]
- : 0;
+ $currentValue = $this->currentCategoryCounts[$result->title] ?? 0;
$cachedValue = intval( $result->value ); // T76910
// If the category has been created or emptied since the list was refreshed, strike it
* @return int
*/
function getSize() {
- return isset( $this->mParams['size'] )
- ? $this->mParams['size']
- : 60;
+ return $this->mParams['size'] ?? 60;
}
}
foreach ( $this->mFlatFields as $fieldname => $field ) {
if ( $field instanceof HTMLNestedFilterable ) {
$info = $field->mParams;
- $prefix = isset( $info['prefix'] ) ? $info['prefix'] : $fieldname;
+ $prefix = $info['prefix'] ?? $fieldname;
foreach ( $field->filterDataForSubmit( $data[$fieldname] ) as $key => $value ) {
$data["$prefix$key"] = $value;
}
foreach ( $this->mFlatFields as $fieldname => $field ) {
if ( $field instanceof HTMLNestedFilterable ) {
$info = $field->mParams;
- $prefix = isset( $info['prefix'] ) ? $info['prefix'] : $fieldname;
+ $prefix = $info['prefix'] ?? $fieldname;
foreach ( $field->filterDataForSubmit( $data[$fieldname] ) as $key => $value ) {
$data["$prefix$key"] = $value;
}
$this->mWatch = !empty( $options['watch'] );
$this->mForReUpload = !empty( $options['forreupload'] );
- $this->mSessionKey = isset( $options['sessionkey'] ) ? $options['sessionkey'] : '';
+ $this->mSessionKey = $options['sessionkey'] ?? '';
$this->mHideIgnoreWarning = !empty( $options['hideignorewarning'] );
$this->mDestWarningAck = !empty( $options['destwarningack'] );
- $this->mDestFile = isset( $options['destfile'] ) ? $options['destfile'] : '';
+ $this->mDestFile = $options['destfile'] ?? '';
- $this->mComment = isset( $options['description'] ) ?
- $options['description'] : '';
+ $this->mComment = $options['description'] ?? '';
- $this->mTextTop = isset( $options['texttop'] )
- ? $options['texttop'] : '';
+ $this->mTextTop = $options['texttop'] ?? '';
- $this->mTextAfterSummary = isset( $options['textaftersummary'] )
- ? $options['textaftersummary'] : '';
+ $this->mTextAfterSummary = $options['textaftersummary'] ?? '';
$sourceDescriptor = $this->getSourceSection();
$descriptor = $sourceDescriptor
$this->messages[$msg] = $this->msg( $msg )->escaped();
}
- $this->target = isset( $options['target'] ) ? $options['target'] : '';
- $this->contribs = isset( $options['contribs'] ) ? $options['contribs'] : 'users';
- $this->namespace = isset( $options['namespace'] ) ? $options['namespace'] : '';
- $this->tagFilter = isset( $options['tagfilter'] ) ? $options['tagfilter'] : false;
- $this->nsInvert = isset( $options['nsInvert'] ) ? $options['nsInvert'] : false;
- $this->associated = isset( $options['associated'] ) ? $options['associated'] : false;
+ $this->target = $options['target'] ?? '';
+ $this->contribs = $options['contribs'] ?? 'users';
+ $this->namespace = $options['namespace'] ?? '';
+ $this->tagFilter = $options['tagfilter'] ?? false;
+ $this->nsInvert = $options['nsInvert'] ?? false;
+ $this->associated = $options['associated'] ?? false;
$this->deletedOnly = !empty( $options['deletedOnly'] );
$this->topOnly = !empty( $options['topOnly'] );
* @return array Options array with processed start and end date filter options
*/
public static function processDateFilter( array $opts ) {
- $start = isset( $opts['start'] ) ? $opts['start'] : '';
- $end = isset( $opts['end'] ) ? $opts['end'] : '';
- $year = isset( $opts['year'] ) ? $opts['year'] : '';
- $month = isset( $opts['month'] ) ? $opts['month'] : '';
+ $start = $opts['start'] ?? '';
+ $end = $opts['end'] ?? '';
+ $year = $opts['year'] ?? '';
+ $month = $opts['month'] ?? '';
if ( $start !== '' && $end !== '' && $start > $end ) {
$temp = $start;
'comment' => CommentStore::getStore()->getComment( 'ar_comment', $row )->text,
'user' => $row->ar_user,
'user_text' => $row->ar_user_text,
- 'actor' => isset( $row->ar_actor ) ? $row->ar_actor : null,
+ 'actor' => $row->ar_actor ?? null,
'timestamp' => $row->ar_timestamp,
'minor_edit' => $row->ar_minor_edit,
'deleted' => $row->ar_deleted,
$user = User::newFromId( $uid );
return $user->getGroupMemberships();
} else {
- return isset( $cache[$uid] ) ? $cache[$uid] : [];
+ return $cache[$uid] ?? [];
}
}
# look up scanner configuration
$command = $wgAntivirusSetup[$wgAntivirus]['command'];
$exitCodeMap = $wgAntivirusSetup[$wgAntivirus]['codemap'];
- $msgPattern = isset( $wgAntivirusSetup[$wgAntivirus]['messagepattern'] ) ?
- $wgAntivirusSetup[$wgAntivirus]['messagepattern'] : null;
+ $msgPattern = $wgAntivirusSetup[$wgAntivirus]['messagepattern'] ?? null;
if ( strpos( $command, "%f" ) === false ) {
# simple pattern: append file to scan
'bp_user' => 0,
'bp_app_id' => isset( $data['appId'] ) ? trim( $data['appId'] ) : '',
'bp_token' => '**unsaved**',
- 'bp_restrictions' => isset( $data['restrictions'] )
- ? $data['restrictions']
- : MWRestrictions::newDefault(),
- 'bp_grants' => isset( $data['grants'] ) ? $data['grants'] : [],
+ 'bp_restrictions' => $data['restrictions'] ?? MWRestrictions::newDefault(),
+ 'bp_grants' => $data['grants'] ?? [],
];
if (
if ( ( isset( $info['type'] ) && $info['type'] == 'multiselect' ) ||
( isset( $info['class'] ) && $info['class'] == HTMLMultiSelectField::class ) ) {
$opts = HTMLFormField::flattenOptions( $info['options'] );
- $prefix = isset( $info['prefix'] ) ? $info['prefix'] : $name;
+ $prefix = $info['prefix'] ?? $name;
foreach ( $opts as $value ) {
$multiselectOptions["$prefix$value"] = true;
( isset( $info['class'] ) && $info['class'] == HTMLCheckMatrix::class ) ) {
$columns = HTMLFormField::flattenOptions( $info['columns'] );
$rows = HTMLFormField::flattenOptions( $info['rows'] );
- $prefix = isset( $info['prefix'] ) ? $info['prefix'] : $name;
+ $prefix = $info['prefix'] ?? $name;
foreach ( $columns as $column ) {
foreach ( $rows as $row ) {
$joinConds
);
- $limit = isset( $dbOptions['LIMIT'] ) ? $dbOptions['LIMIT'] : INF;
+ $limit = $dbOptions['LIMIT'] ?? INF;
$items = [];
$startFrom = null;
foreach ( $res as $row ) {
$config['title'],
[
'relative' => true,
- 'namespace' => isset( $config['namespace']['value'] ) ?
- $config['namespace']['value'] :
- null,
+ 'namespace' => $config['namespace']['value'] ?? null,
]
) );
parent::__construct( $options );
$this->noDatePicker = $options['noDatePicker'];
- $this->required = isset( $options['required'] ) ? $options['required'] : false;
+ $this->required = $options['required'] ?? false;
// Properties
$this->relativeInput = $relativeInput;
parent::__construct( $config );
// Properties
- $this->includeAllValue = isset( $config['includeAllValue'] ) ? $config['includeAllValue'] : null;
- $this->exclude = isset( $config['exclude'] ) ? $config['exclude'] : [];
+ $this->includeAllValue = $config['includeAllValue'] ?? null;
+ $this->exclude = $config['exclude'] ?? [];
// Initialization
$this->addClasses( [ 'mw-widget-namespaceInputWidget' ] );
protected function getNamespaceDropdownOptions( array $config ) {
$namespaceOptionsParams = [
- 'all' => isset( $config['includeAllValue'] ) ? $config['includeAllValue'] : null,
- 'exclude' => isset( $config['exclude'] ) ? $config['exclude'] : null
+ 'all' => $config['includeAllValue'] ?? null,
+ 'exclude' => $config['exclude'] ?? null
];
$namespaceOptions = \Html::namespaceSelectorOptions( $namespaceOptionsParams );
}
// get the language object to process
- $langObj = isset( self::$mLangObjCache[$code] )
- ? self::$mLangObjCache[$code]
- : self::newFromCode( $code );
+ $langObj = self::$mLangObjCache[$code] ?? self::newFromCode( $code );
// merge the language object in to get it up front in the cache
self::$mLangObjCache = array_merge( [ $code => $langObj ], self::$mLangObjCache );
*/
public function getNsText( $index ) {
$ns = $this->getNamespaces();
- return isset( $ns[$index] ) ? $ns[$index] : false;
+ return $ns[$index] ?? false;
}
/**
$ns = $wgExtraGenderNamespaces +
(array)self::$dataCache->getItem( $this->mCode, 'namespaceGenderAliases' );
- return isset( $ns[$index][$gender] ) ? $ns[$index][$gender] : $this->getNsText( $index );
+ return $ns[$index][$gender] ?? $this->getNsText( $index );
}
/**
function getLocalNsIndex( $text ) {
$lctext = $this->lc( $text );
$ids = $this->getNamespaceIds();
- return isset( $ids[$lctext] ) ? $ids[$lctext] : false;
+ return $ids[$lctext] ?? false;
}
/**
return $ns;
}
$ids = $this->getNamespaceIds();
- return isset( $ids[$lctext] ) ? $ids[$lctext] : false;
+ return $ids[$lctext] ?? false;
}
/**
if ( $gender === 'female' ) {
return $forms[1];
}
- return isset( $forms[2] ) ? $forms[2] : $forms[0];
+ return $forms[2] ?? $forms[0];
}
/**
protected function cleanupTable( $tableParams ) {
$table = $tableParams[0];
$prefix = $tableParams[1];
- $idField = isset( $tableParams['idField'] ) ?
- $tableParams['idField'] :
- "{$prefix}_id";
- $nsField = isset( $tableParams['nsField'] ) ?
- $tableParams['nsField'] :
- "{$prefix}_namespace";
- $titleField = isset( $tableParams['titleField'] ) ?
- $tableParams['titleField'] :
- "{$prefix}_title";
+ $idField = $tableParams['idField'] ?? "{$prefix}_id";
+ $nsField = $tableParams['nsField'] ?? "{$prefix}_namespace";
+ $titleField = $tableParams['titleField'] ?? "{$prefix}_title";
$this->outputStatus( "Looking for invalid $titleField entries in $table...\n" );
$dPathSha1 = sha1( $dPath );
if ( $this->statCache !== null ) {
// All dst files are already in stat cache
- $dstStat = isset( $this->statCache[$dPathSha1] )
- ? $this->statCache[$dPathSha1]
- : false;
+ $dstStat = $this->statCache[$dPathSha1] ?? false;
} else {
$dstStat = $dst->getFileStat( [ 'src' => $dPath ] );
}
* @return string
*/
function priority( $namespace ) {
- return isset( $this->priorities[$namespace] )
- ? $this->priorities[$namespace]
- : $this->guessPriority( $namespace );
+ return $this->priorities[$namespace] ?? $this->guessPriority( $namespace );
}
/**
$debug = isset( $options['debug'] );
$help = isset( $options['help'] );
-$cache = isset( $options['cache'] ) ? $options['cache'] : null;
+$cache = $options['cache'] ?? null;
if ( $help ) {
mccShowUsage();
} else {
// Use nice safe, sane, prefixes
preg_match( '/^[a-zA-Z]+_$/', $this->getOption( 'old' ), $m );
- $old = isset( $m[0] ) ? $m[0] : false;
+ $old = $m[0] ?? false;
}
// Allow for no new prefix
if ( $this->getOption( 'new', 0 ) === '0' ) {
} else {
// Use nice safe, sane, prefixes
preg_match( '/^[a-zA-Z]+_$/', $this->getOption( 'new' ), $m );
- $new = isset( $m[0] ) ? $m[0] : false;
+ $new = $m[0] ?? false;
}
if ( $old === false || $new === false ) {
} else {
$maxID = $dbw->selectField( 'text', 'MAX(old_id)', '', $fname );
}
- $minID = isset( $options['s'] ) ? $options['s'] : 1;
+ $minID = $options['s'] ?? 1;
moveToExternal( $cluster, $maxID, $minID );
}
$limit = 1000;
$untilHappy = true;
}
-$type = isset( $options['type'] ) ? $options['type'] : ConcatenatedGzipHistoryBlob::class;
+$type = $options['type'] ?? ConcatenatedGzipHistoryBlob::class;
$dbr = $this->getDB( DB_REPLICA );
$revQuery = Revision::getQueryInfo( [ 'page', 'text' ] );
return [
'cluster' => $m[1],
'id' => intval( $m[2] ),
- 'hash' => isset( $m[3] ) ? $m[3] : null
+ 'hash' => $m[3] ?? null
];
}
foreach ( QueryPage::getPages() as $page ) {
list( $class, $special ) = $page;
- $limit = isset( $page[2] ) ? $page[2] : null;
+ $limit = $page[2] ?? null;
# --list : just show the name of pages
if ( $this->hasOption( 'list' ) ) {
$this->keepUploads = !empty( $options['keep-uploads'] );
- $this->fileBackendName = isset( $options['file-backend'] ) ?
- $options['file-backend'] : false;
+ $this->fileBackendName = $options['file-backend'] ?? false;
$this->runDisabled = !empty( $options['run-disabled'] );
$this->runParsoid = !empty( $options['run-parsoid'] );
if ( is_int( $name ) ) {
$value();
} else {
- $saved[$name] = isset( $GLOBALS[$name] ) ? $GLOBALS[$name] : null;
+ $saved[$name] = $GLOBALS[$name] ?? null;
$GLOBALS[$name] = $value;
}
}
* @return bool
*/
public function isSetupDone( $funcName ) {
- return isset( $this->setupDone[$funcName] ) ? $this->setupDone[$funcName] : false;
+ return $this->setupDone[$funcName] ?? false;
}
/**
}
$local = isset( $opts['local'] );
- $preprocessor = isset( $opts['preprocessor'] ) ? $opts['preprocessor'] : null;
+ $preprocessor = $opts['preprocessor'] ?? null;
$parser = $this->getParser( $preprocessor );
$title = Title::newFromText( $titleText );
$singletons = $wrappedProvider->singletons;
if ( $provider instanceof MonologSpi ) {
if ( !isset( $this->loggers[$channel] ) ) {
- $this->loggers[$channel] = isset( $singletons['loggers'][$channel] )
- ? $singletons['loggers'][$channel] : null;
+ $this->loggers[$channel] = $singletons['loggers'][$channel] ?? null;
}
$singletons['loggers'][$channel] = $logger;
} elseif ( $provider instanceof LegacySpi ) {
if ( !isset( $this->loggers[$channel] ) ) {
- $this->loggers[$channel] = isset( $singletons[$channel] ) ? $singletons[$channel] : null;
+ $this->loggers[$channel] = $singletons[$channel] ?? null;
}
$singletons[$channel] = $logger;
} else {
*/
private function setUpSchema( IMaintainableDatabase $db ) {
// Undo any active overrides.
- $oldOverrides = isset( $db->_schemaOverrides ) ? $db->_schemaOverrides
- : self::$schemaOverrideDefaults;
+ $oldOverrides = $db->_schemaOverrides ?? self::$schemaOverrideDefaults;
if ( $oldOverrides['alter'] || $oldOverrides['create'] || $oldOverrides['drop'] ) {
$this->undoSchemaOverrides( $db, $oldOverrides );
$expected = $this->extractExpect( $server, $expectations );
// save up global
- $old = isset( $_SERVER['SERVER_SOFTWARE'] )
- ? $_SERVER['SERVER_SOFTWARE']
- : null;
+ $old = $_SERVER['SERVER_SOFTWARE'] ?? null;
$_SERVER['SERVER_SOFTWARE'] = $server;
wfUrlencode( null );
$ret[] = [
$case[0],
$case[1], $case[2],
- isset( $case[3] ) ? $case[3] : ''
+ $case[3] ?? ''
];
}
public function testSearch( array $case ) {
$this->searchProvision( null );
- $namespaces = isset( $case['namespaces'] ) ? $case['namespaces'] : [];
+ $namespaces = $case['namespaces'] ?? [];
if ( wfGetDB( DB_REPLICA )->getType() === 'postgres' ) {
// Postgres will sort lexicographically on utf8 code units (" " before "/")
public function testSearchWithOffset( array $case ) {
$this->searchProvision( null );
- $namespaces = isset( $case['namespaces'] ) ? $case['namespaces'] : [];
+ $namespaces = $case['namespaces'] ?? [];
$searcher = new StringPrefixSearch;
$results = $searcher->search( $case['query'], 3, $namespaces, 1 );
sort( $groups );
$key = implode( ',', $groups );
- $testUser = isset( self::$testUsers[$key] )
- ? self::$testUsers[$key]
- : false;
+ $testUser = self::$testUsers[$key] ?? false;
if ( !$testUser || !$testUser->getUser()->isLoggedIn() ) {
$id = self::getNextId();
$input !== null ? [ 'myParam' => $input ] : [] ) );
$wrapper->mMainModule = new ApiMain( $context );
- $parseLimits = isset( $options['parseLimits'] ) ?
- $options['parseLimits'] : true;
+ $parseLimits = $options['parseLimits'] ?? true;
if ( !empty( $options['apihighlimits'] ) ) {
$context->setUser( self::$users['sysop']->getUser() );
];
foreach ( $integerTests as $test ) {
- $desc = isset( $test[2] ) ? $test[2] : $test[0];
+ $desc = $test[2] ?? $test[0];
$warnings = isset( $test[3] ) ?
[ [ 'apiwarn-badutf8', 'myParam' ] ] : [];
$returnArray["\"$desc\" as integer"] = [
$value = self::$repl[$m[1]];
} else {
$value = preg_replace_callback( '/{{REPL:(.+?)}}/', function ( $m ) {
- return isset( self::$repl[$m[1]] ) ? self::$repl[$m[1]] : $m[0];
+ return self::$repl[$m[1]] ?? $m[0];
}, $value );
}
} elseif ( is_array( $value ) || is_object( $value ) ) {
$module->expects( $this->any() )
->method( 'getConditionalRequestData' )
->will( $this->returnCallback( function ( $condition ) use ( $conditions ) {
- return isset( $conditions[$condition] ) ? $conditions[$condition] : null;
+ return $conditions[$condition] ?? null;
} ) );
$ret = $priv->checkConditionalRequestHeaders( $module );
$module->expects( $this->any() )
->method( 'getConditionalRequestData' )
->will( $this->returnCallback( function ( $condition ) use ( $conditions ) {
- return isset( $conditions[$condition] ) ? $conditions[$condition] : null;
+ return $conditions[$condition] ?? null;
} ) );
$priv->mModule = $module;
foreach ( [ 'Last-Modified', 'ETag' ] as $header ) {
$this->assertEquals(
- isset( $headers[$header] ) ? $headers[$header] : null,
+ $headers[$header] ?? null,
$response->getHeader( $header ),
$header
);
if ( $options['name'] !== 'mockfm' ) {
$ct = 'text/x-mock';
$file = 'api-result.mock';
- $status = isset( $options['status'] ) ? $options['status'] : null;
+ $status = $options['status'] ?? null;
} elseif ( isset( $params['wrappedhtml'] ) ) {
$ct = 'text/mediawiki-api-prettyprint-wrapped';
$file = 'api-result-wrapped.json';
if ( is_string( $options ) ) {
$options = [ 'class' => $options ];
}
- $printerName = isset( $options['name'] ) ? $options['name'] : $this->printerName;
+ $printerName = $options['name'] ?? $this->printerName;
$context = new RequestContext;
$context->setRequest( new FauxRequest( $params, true ) );
$main = new ApiMain( $context );
if ( isset( $options['class'] ) ) {
- $factory = isset( $options['factory'] ) ? $options['factory'] : null;
+ $factory = $options['factory'] ?? null;
$main->getModuleManager()->addModule( $printerName, 'format', $options['class'], $factory );
}
$result = $main->getResult();
];
$options = getopt( null, $getOptSpec );
- $format = isset( $options['format'] ) ? $options['format'] : 'jpg';
+ $format = $options['format'] ?? 'jpg';
unset( $options['format'] );
$number = isset( $options['number'] ) ? intval( $options['number'] ) : 10;
$this->assertArrayHasKey( 'query', $apiResult[0], "Batching with limit $limit" );
$this->assertArrayHasKey( 'usercontribs', $apiResult[0]['query'],
"Batching with limit $limit" );
- $continue = isset( $apiResult[0]['continue'] ) ? $apiResult[0]['continue'] : null;
+ $continue = $apiResult[0]['continue'] ?? null;
foreach ( $apiResult[0]['query']['usercontribs'] as $page ) {
$count++;
$batchedIds[$page['user']][] = $page['revid'];
}
$state = $session->getSecret( 'AuthManager::authnState' );
- $maybeLink = isset( $state['maybeLink'] ) ? $state['maybeLink'] : [];
+ $maybeLink = $state['maybeLink'] ?? [];
if ( $link && $response->status === AuthenticationResponse::RESTART ) {
$this->assertEquals(
$response->createRequest->maybeLink,
*/
public function testUserName( $userKey, $expectedGender ) {
$genderCache = MediaWikiServices::getInstance()->getGenderCache();
- $username = isset( self::$nameMap[$userKey] ) ? self::$nameMap[$userKey] : $userKey;
+ $username = self::$nameMap[$userKey] ?? $userKey;
$gender = $genderCache->getGenderOf( $username );
$this->assertEquals( $gender, $expectedGender, "GenderCache normal" );
}
* @covers GenderCache::getGenderOf
*/
public function testUserObjects( $userKey, $expectedGender ) {
- $username = isset( self::$nameMap[$userKey] ) ? self::$nameMap[$userKey] : $userKey;
+ $username = self::$nameMap[$userKey] ?? $userKey;
$genderCache = MediaWikiServices::getInstance()->getGenderCache();
$gender = $genderCache->getGenderOf( $username );
$this->assertEquals( $gender, $expectedGender, "GenderCache normal" );
* @covers GenderCache::getGenderOf
*/
public function testStripSubpages( $userKey, $expectedGender ) {
- $username = isset( self::$nameMap[$userKey] ) ? self::$nameMap[$userKey] : $userKey;
+ $username = self::$nameMap[$userKey] ?? $userKey;
$genderCache = MediaWikiServices::getInstance()->getGenderCache();
$gender = $genderCache->getGenderOf( "$username/subpage" );
$this->assertEquals( $gender, $expectedGender, "GenderCache must strip of subpages" );
$this->profiler = new ProfilerStub( [] );
$this->trxProfiler = new TransactionProfiler();
- $this->cliMode = isset( $opts['cliMode'] ) ? $opts['cliMode'] : true;
+ $this->cliMode = $opts['cliMode'] ?? true;
$this->connLogger = new \Psr\Log\NullLogger();
$this->queryLogger = new \Psr\Log\NullLogger();
$this->errorLogger = function ( Exception $e ) {
}
protected function wasKnownStatementRollbackError() {
- return isset( $this->lastError['wasKnownStatementRollbackError'] )
- ? $this->lastError['wasKnownStatementRollbackError']
- : false;
+ return $this->lastError['wasKnownStatementRollbackError'] ?? false;
}
function fieldInfo( $table, $field ) {
$this->database->select(
$sql['tables'],
$sql['fields'],
- isset( $sql['conds'] ) ? $sql['conds'] : [],
+ $sql['conds'] ?? [],
__METHOD__,
- isset( $sql['options'] ) ? $sql['options'] : [],
- isset( $sql['join_conds'] ) ? $sql['join_conds'] : []
+ $sql['options'] ?? [],
+ $sql['join_conds'] ?? []
);
$this->assertLastSql( $sqlText );
}
$this->database->selectRowCount(
$sql['tables'],
$sql['field'],
- isset( $sql['conds'] ) ? $sql['conds'] : [],
+ $sql['conds'] ?? [],
__METHOD__,
- isset( $sql['options'] ) ? $sql['options'] : [],
- isset( $sql['join_conds'] ) ? $sql['join_conds'] : []
+ $sql['options'] ?? [],
+ $sql['join_conds'] ?? []
);
$this->assertLastSql( $sqlText );
}
$sql['values'],
$sql['conds'],
__METHOD__,
- isset( $sql['options'] ) ? $sql['options'] : []
+ $sql['options'] ?? []
);
$this->assertLastSql( $sqlText );
}
$sql['table'],
$sql['rows'],
__METHOD__,
- isset( $sql['options'] ) ? $sql['options'] : []
+ $sql['options'] ?? []
);
$this->assertLastSql( $sqlText );
}
$sql['varMap'],
$sql['conds'],
__METHOD__,
- isset( $sql['insertOptions'] ) ? $sql['insertOptions'] : [],
- isset( $sql['selectOptions'] ) ? $sql['selectOptions'] : [],
- isset( $sql['selectJoinConds'] ) ? $sql['selectJoinConds'] : []
+ $sql['insertOptions'] ?? [],
+ $sql['selectOptions'] ?? [],
+ $sql['selectJoinConds'] ?? []
);
$this->assertLastSql( $sqlTextNative );
$sql['varMap'],
$sql['conds'],
__METHOD__,
- isset( $sql['insertOptions'] ) ? $sql['insertOptions'] : [],
- isset( $sql['selectOptions'] ) ? $sql['selectOptions'] : [],
- isset( $sql['selectJoinConds'] ) ? $sql['selectJoinConds'] : []
+ $sql['insertOptions'] ?? [],
+ $sql['selectOptions'] ?? [],
+ $sql['selectJoinConds'] ?? []
);
$this->assertLastSqlDb( implode( '; ', [ $sqlSelect, 'BEGIN', $sqlInsert, 'COMMIT' ] ), $dbWeb );
}
$params['table'],
$params['vars'],
$params['permute_conds'],
- isset( $params['extra_conds'] ) ? $params['extra_conds'] : '',
+ $params['extra_conds'] ?? '',
'FNAME',
- isset( $params['options'] ) ? $params['options'] : [],
- isset( $params['join_conds'] ) ? $params['join_conds'] : []
+ $params['options'] ?? [],
+ $params['join_conds'] ?? []
) );
$this->assertEquals( $expect, $sql );
}
// no log_id because no insert in database
'log_type' => $data['type'],
'log_action' => $data['action'],
- 'log_timestamp' => isset( $data['timestamp'] ) ? $data['timestamp'] : wfTimestampNow(),
- 'log_user' => isset( $data['user'] ) ? $data['user'] : 0,
- 'log_user_text' => isset( $data['user_text'] ) ? $data['user_text'] : 'User',
- 'log_actor' => isset( $data['actor'] ) ? $data['actor'] : 0,
- 'log_namespace' => isset( $data['namespace'] ) ? $data['namespace'] : NS_MAIN,
- 'log_title' => isset( $data['title'] ) ? $data['title'] : 'Main_Page',
- 'log_page' => isset( $data['page'] ) ? $data['page'] : 0,
- 'log_comment_text' => isset( $data['comment'] ) ? $data['comment'] : '',
+ 'log_timestamp' => $data['timestamp'] ?? wfTimestampNow(),
+ 'log_user' => $data['user'] ?? 0,
+ 'log_user_text' => $data['user_text'] ?? 'User',
+ 'log_actor' => $data['actor'] ?? 0,
+ 'log_namespace' => $data['namespace'] ?? NS_MAIN,
+ 'log_title' => $data['title'] ?? 'Main_Page',
+ 'log_page' => $data['page'] ?? 0,
+ 'log_comment_text' => $data['comment'] ?? '',
'log_comment_data' => null,
'log_params' => $legacy
? LogPage::makeParamBlob( $data['params'] )
: LogEntryBase::makeParamBlob( $data['params'] ),
- 'log_deleted' => isset( $data['deleted'] ) ? $data['deleted'] : 0,
+ 'log_deleted' => $data['deleted'] ?? 0,
];
}
$this->setMwGlobals( 'wgResourceLoaderSources', $case['sources'] );
}
- $extraQuery = isset( $case['extraQuery'] ) ? $case['extraQuery'] : [];
+ $extraQuery = $case['extraQuery'] ?? [];
$context = $this->getResourceLoaderContext( $extraQuery );
$rl = $context->getResourceLoader();
$rl->register( $case['modules'] );
$output->method( 'redirect' )->willReturnCallback(
function ( $url ) use ( &$redirectQuery, &$redirected ) {
$urlParts = wfParseUrl( $url );
- $query = isset( $urlParts[ 'query' ] ) ? $urlParts[ 'query' ] : '';
+ $query = $urlParts[ 'query' ] ?? '';
parse_str( $query, $redirectQuery );
$redirected = true;
}
$params = array_map( 'cssfilter', $_GET );
// Defaults
-$selector = isset( $params['selector'] ) ? $params['selector'] : '.mw-test-example';
-$property = isset( $params['prop'] ) ? $params['prop'] : 'float';
-$value = isset( $params['val'] ) ? $params['val'] : 'right';
+$selector = $params['selector'] ?? '.mw-test-example';
+$property = $params['prop'] ?? 'float';
+$value = $params['val'] ?? 'right';
$wait = isset( $params['wait'] ) ? (int)$params['wait'] : 0; // seconds
sleep( $wait );
$headers = []; // HTTP headers to send
- $fileName = isset( $params['f'] ) ? $params['f'] : '';
+ $fileName = $params['f'] ?? '';
// Backwards compatibility parameters
if ( isset( $params['w'] ) ) {
}
}
- $rel404 = isset( $params['rel404'] ) ? $params['rel404'] : null;
+ $rel404 = $params['rel404'] ?? null;
unset( $params['r'] ); // ignore 'r' because we unconditionally pass File::RENDER
unset( $params['f'] ); // We're done with 'f' parameter.
unset( $params['rel404'] ); // moved to $rel404
if ( $wgShowHostnames ) {
header( 'X-MW-Thumbnail-Renderer: ' . wfHostname() );
$url = htmlspecialchars(
- isset( $_SERVER['REQUEST_URI'] ) ? $_SERVER['REQUEST_URI'] : '',
+ $_SERVER['REQUEST_URI'] ?? '',
ENT_NOQUOTES
);
$hostname = htmlspecialchars( wfHostname(), ENT_NOQUOTES );