// 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;
} );
}
);
# Add the results to the link cache
- $lb->addResultToCache( LinkCache::singleton(), $res );
+ $linkCache = MediaWikiServices::getInstance()->getLinkCache();
+ $lb->addResultToCache( $linkCache, $res );
return $res;
}
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;
}
}
foreach ( $errors as $error ) {
$text .= '<li>';
- $text .= call_user_func_array( [ $this, 'msg' ], $error )->plain();
+ $text .= $this->msg( ...$error )->plain();
$text .= "</li>\n";
}
$text .= '</ul>';
} else {
$text .= "<div class=\"permissions-errors\">\n" .
- call_user_func_array( [ $this, 'msg' ], reset( $errors ) )->plain() .
+ $this->msg( ...reset( $errors ) )->plain() .
"\n</div>";
}
*/
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() );
uksort( $logosPerDppx, function ( $a , $b ) {
$a = floatval( $a );
$b = floatval( $b );
-
- if ( $a == $b ) {
- return 0;
- }
// Sort from smallest to largest (e.g. 1x, 1.5x, 2x)
- return ( $a < $b ) ? -1 : 1;
+ return $a <=> $b;
} );
foreach ( $logosPerDppx as $dppx => $src ) {
}
if ( $this->CSPNonce === null ) {
// XXX It might be expensive to generate randomness
- // on every request, on windows.
- $rand = MWCryptRand::generate( 15 );
+ // on every request, on Windows.
+ $rand = random_bytes( 15 );
$this->CSPNonce = base64_encode( $rand );
}
return $this->CSPNonce;