Don't use setOption() in loadDefaultFromLanguage, as this triggers some slow reloading.
Code style tweaks and profiling points.
This commit is contained in:
parent
74bcce57a6
commit
8e1cd3312f
1 changed files with 33 additions and 14 deletions
|
|
@ -137,6 +137,11 @@ class User {
|
||||||
* if we have an available language object.
|
* if we have an available language object.
|
||||||
*/
|
*/
|
||||||
function loadDefaults() {
|
function loadDefaults() {
|
||||||
|
static $n=0;
|
||||||
|
$n++;
|
||||||
|
$fname = 'User::loadDefaults' . $n;
|
||||||
|
wfProfileIn( $fname );
|
||||||
|
|
||||||
global $wgContLang, $wgIP;
|
global $wgContLang, $wgIP;
|
||||||
global $wgNamespacesToBeSearchedDefault;
|
global $wgNamespacesToBeSearchedDefault;
|
||||||
|
|
||||||
|
|
@ -149,9 +154,11 @@ class User {
|
||||||
$this->mGroups = array();
|
$this->mGroups = array();
|
||||||
|
|
||||||
// Getting user defaults only if we have an available language
|
// Getting user defaults only if we have an available language
|
||||||
if(isset($wgContLang)) { $this->loadDefaultFromLanguage(); }
|
if( isset( $wgContLang ) ) {
|
||||||
|
$this->loadDefaultFromLanguage();
|
||||||
|
}
|
||||||
|
|
||||||
foreach ($wgNamespacesToBeSearchedDefault as $nsnum => $val) {
|
foreach( $wgNamespacesToBeSearchedDefault as $nsnum => $val ) {
|
||||||
$this->mOptions['searchNs'.$nsnum] = $val;
|
$this->mOptions['searchNs'.$nsnum] = $val;
|
||||||
}
|
}
|
||||||
unset( $this->mSkin );
|
unset( $this->mSkin );
|
||||||
|
|
@ -160,6 +167,7 @@ class User {
|
||||||
$this->mTouched = '0'; # Allow any pages to be cached
|
$this->mTouched = '0'; # Allow any pages to be cached
|
||||||
$this->setToken(); # Random
|
$this->setToken(); # Random
|
||||||
$this->mHash = false;
|
$this->mHash = false;
|
||||||
|
wfProfileOut( $fname );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -168,19 +176,25 @@ class User {
|
||||||
* a language object.
|
* a language object.
|
||||||
*/
|
*/
|
||||||
function loadDefaultFromLanguage(){
|
function loadDefaultFromLanguage(){
|
||||||
global $wgContLang;
|
$fname = 'User::loadDefaultFromLanguage';
|
||||||
global $wgDefaultUserOptions;
|
wfProfileIn( $fname );
|
||||||
|
|
||||||
# Site defaults will override the global/language defaults
|
/**
|
||||||
$defOpt = $wgDefaultUserOptions + $wgContLang->getDefaultUserOptions();
|
* Site defaults will override the global/language defaults
|
||||||
foreach ( $defOpt as $oname => $val ) {
|
|
||||||
$this->mOptions[$oname] = $val;
|
|
||||||
}
|
|
||||||
/*
|
|
||||||
default language setting
|
|
||||||
*/
|
*/
|
||||||
$this->setOption('variant', $wgContLang->getPreferredVariant());
|
global $wgContLang, $wgDefaultUserOptions;
|
||||||
$this->setOption('language', $wgContLang->getPreferredVariant());
|
$defOpt = $wgDefaultUserOptions + $wgContLang->getDefaultUserOptions();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* default language setting
|
||||||
|
*/
|
||||||
|
$variant = $wgContLang->getPreferredVariant();
|
||||||
|
$defOpt['variant'] = $variant;
|
||||||
|
$defOpt['language'] = $variant;
|
||||||
|
|
||||||
|
$this->mOptions = $defOpt;
|
||||||
|
|
||||||
|
wfProfileOut();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -649,8 +663,12 @@ class User {
|
||||||
function &getSkin() {
|
function &getSkin() {
|
||||||
global $IP;
|
global $IP;
|
||||||
if ( ! isset( $this->mSkin ) ) {
|
if ( ! isset( $this->mSkin ) ) {
|
||||||
|
$fname = 'User::getSkin';
|
||||||
|
wfProfileIn( $fname );
|
||||||
|
|
||||||
# get all skin names available
|
# get all skin names available
|
||||||
$skinNames = Skin::getSkinNames();
|
$skinNames = Skin::getSkinNames();
|
||||||
|
|
||||||
# get the user skin
|
# get the user skin
|
||||||
$userSkin = $this->getOption( 'skin' );
|
$userSkin = $this->getOption( 'skin' );
|
||||||
if ( $userSkin == '' ) { $userSkin = 'standard'; }
|
if ( $userSkin == '' ) { $userSkin = 'standard'; }
|
||||||
|
|
@ -691,7 +709,8 @@ class User {
|
||||||
$className = 'SkinStandard';
|
$className = 'SkinStandard';
|
||||||
require_once( $IP.'/skins/Standard.php' );
|
require_once( $IP.'/skins/Standard.php' );
|
||||||
}
|
}
|
||||||
$this->mSkin = new $className;
|
$this->mSkin =& new $className;
|
||||||
|
wfProfileOut( $fname );
|
||||||
}
|
}
|
||||||
return $this->mSkin;
|
return $this->mSkin;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue