'UserGetLanguageObject': Called when getting user's interface language object.
$user: User object
&$code: Langauge code that will be used to create the object
+$context: RequestContext object
'UserGetReservedNames': Allows to modify $wgReservedUsernames at run time.
&$reservedUsernames: $wgReservedUsernames
}
/**
- * Get the Language object
+ * Get the Language object.
+ * Initialization of user or request objects can depend on this.
*
* @return Language
* @since 1.19
*/
public function getLanguage() {
+ if ( isset( $this->recursion ) ) {
+ throw new MWException( 'Recursion detected' );
+ }
+
if ( $this->lang === null ) {
+ $this->recursion = true;
+
global $wgLanguageCode, $wgContLang;
- $code = $this->getRequest()->getVal(
- 'uselang',
- $this->getUser()->getOption( 'language' )
- );
+
+ $request = $this->getRequest();
+ $user = $this->getUser();
+
+ $code = $request->getVal( 'uselang', $user->getOption( 'language' ) );
$code = self::sanitizeLangCode( $code );
- wfRunHooks( 'UserGetLanguageObject', array( $this->getUser(), &$code ) );
+ wfRunHooks( 'UserGetLanguageObject', array( $user, &$code, $this ) );
if ( $code === $wgLanguageCode ) {
$this->lang = $wgContLang;
$obj = Language::factory( $code );
$this->lang = $obj;
}
+
+ unset( $this->recursion );
}
+
return $this->lang;
}
* - Skin will be based on the anonymous user, should be the wiki's default skin
*
* @param Title $title Title to use for the extraneous request
- * @param mixed $request A WebRequest or data to use for a FauxRequest
+ * @param WebRequest|array $request A WebRequest or data to use for a FauxRequest
* @return RequestContext
*/
public static function newExtraneousContext( Title $title, $request = array() ) {