* Create a new object to replace this stub object.
*/
function _newObject() {
- return wfCreateObject( $this->mClass, $this->mParams );
+ return MWFunction::newObj( $this->mClass, $this->mParams );
}
/**
throw new MWException( "Unstub loop detected on call of \${$this->mGlobal}->$name from $caller\n" );
}
wfDebug( "Unstubbing \${$this->mGlobal} on call of \${$this->mGlobal}::$name from $caller\n" );
- $obj = $GLOBALS[$this->mGlobal] = $this->_newObject();
+ $GLOBALS[$this->mGlobal] = $this->_newObject();
--$recursionLevel;
wfProfileOut( $fname );
}
}
function _newObject() {
- global $wgContLanguageCode;
- $obj = Language::factory( $wgContLanguageCode );
+ global $wgLanguageCode;
+ $obj = Language::factory( $wgLanguageCode );
$obj->initEncoding();
$obj->initContLang();
return $obj;
}
function _newObject() {
- global $wgContLanguageCode, $wgRequest, $wgUser, $wgContLang;
+ global $wgLanguageCode, $wgRequest, $wgUser, $wgContLang;
$code = $wgRequest->getVal( 'uselang', $wgUser->getOption( 'language' ) );
// BCP 47 - letter case MUST NOT carry meaning
$code = strtolower( $code );
# Validate $code
- if( empty( $code ) || !preg_match( '/^[a-z-]+$/', $code ) || ( $code === 'qqq' ) ) {
+ if( empty( $code ) || !Language::isValidCode( $code ) || ( $code === 'qqq' ) ) {
wfDebug( "Invalid user language code\n" );
- $code = $wgContLanguageCode;
+ $code = $wgLanguageCode;
}
- if( $code === $wgContLanguageCode ) {
+ wfRunHooks( 'UserGetLanguageObject', array( $wgUser, &$code ) );
+
+ if( $code === $wgLanguageCode ) {
return $wgContLang;
} else {
$obj = Language::factory( $code );
}
}
}
-
-/**
- * Stub object for the user. The initialisation of the will depend of
- * $wgCommandLineMode. If it's true, it will be an anonymous user and if it's
- * false, the user will be loaded from credidentails provided by cookies. This
- * object have to be in $wgUser global.
- */
-class StubUser extends StubObject {
-
- function __construct() {
- parent::__construct( 'wgUser' );
- }
-
- function __call( $name, $args ) {
- return $this->_call( $name, $args );
- }
-
- function _newObject() {
- global $wgCommandLineMode;
- if( $wgCommandLineMode ) {
- $user = new User;
- } else {
- $user = User::newFromSession();
- }
- return $user;
- }
-}