*/
private static $instance = null;
+ /**
+ * Boolean flag to guard against recursion in getLanguage
+ * @var bool
+ */
+ private $languageRecursion = false;
+
/**
* @param Config $config
*/
* @since 1.19
*/
public function getLanguage() {
- if ( isset( $this->recursion ) ) {
+ if ( $this->languageRecursion === true ) {
trigger_error( "Recursion detected in " . __METHOD__, E_USER_WARNING );
$e = new Exception;
wfDebugLog( 'recursion-guard', "Recursion detected:\n" . $e->getTraceAsString() );
$code = $this->getConfig()->get( 'LanguageCode' ) ?: 'en';
$this->lang = Language::factory( $code );
} elseif ( $this->lang === null ) {
- $this->recursion = true;
+ $this->languageRecursion = true;
try {
$request = $this->getRequest();
$user = $this->getUser();
- $code = $request->getVal( 'uselang', 'user' );
+ // Optimisation: Avoid slow getVal(), this isn't user-generated content.
+ $code = $request->getRawVal( 'uselang', 'user' );
if ( $code === 'user' ) {
$code = $user->getOption( 'language' );
}
$this->lang = $obj;
}
} finally {
- unset( $this->recursion );
+ $this->languageRecursion = false;
}
}
// No hook override, go through normal processing
if ( !in_array( 'skin', $this->getConfig()->get( 'HiddenPrefs' ) ) ) {
$userSkin = $this->getUser()->getOption( 'skin' );
- $userSkin = $this->getRequest()->getVal( 'useskin', $userSkin );
+ // Optimisation: Avoid slow getVal(), this isn't user-generated content.
+ $userSkin = $this->getRequest()->getRawVal( 'useskin', $userSkin );
} else {
$userSkin = $this->getConfig()->get( 'DefaultSkin' );
}
*
* @param string|string[]|MessageSpecifier $key Message key, or array of keys,
* or a MessageSpecifier.
- * @param mixed $args,...
+ * @param mixed ...$params
* @return Message
*/
- public function msg( $key ) {
- $args = func_get_args();
-
- return wfMessage( ...$args )->setContext( $this );
+ public function msg( $key, ...$params ) {
+ return wfMessage( $key, ...$params )->setContext( $this );
}
/**