* 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 );