From: Chad Horohoe Date: Thu, 12 Aug 2010 17:10:00 +0000 (+0000) Subject: Get rid of StubUser. Constructing a user object isn't quite as intensive as it once... X-Git-Tag: 1.31.0-rc.0~35520 X-Git-Url: http://git.cyclocoop.org/%22%20.%20generer_url_ecrire%28%22calendrier%22%2C%22type=semaine%22%29%20.%20%22?a=commitdiff_plain;h=985e8971c8ceede96feb8e4e30a79ddf32109eb6;p=lhc%2Fweb%2Fwiklou.git Get rid of StubUser. Constructing a user object isn't quite as intensive as it once was. It actually takes more time using the StubUser (construction + unstub on first call) than just initializing User::newFromSession() from the start. Either way, the real overhead starts when you start calling methods (for the nitpicky, the optimization was only about 20µs. The real gain here was eliminating a StubObject) --- diff --git a/includes/AutoLoader.php b/includes/AutoLoader.php index 52b6bd57a2..a42398a325 100644 --- a/includes/AutoLoader.php +++ b/includes/AutoLoader.php @@ -214,7 +214,6 @@ $wgAutoloadLocalClasses = array( 'SquidPurgeClientPool' => 'includes/SquidPurgeClient.php', 'Status' => 'includes/Status.php', 'StubContLang' => 'includes/StubObject.php', - 'StubUser' => 'includes/StubObject.php', 'StubUserLang' => 'includes/StubObject.php', 'StubObject' => 'includes/StubObject.php', 'StringUtils' => 'includes/StringUtils.php', diff --git a/includes/Setup.php b/includes/Setup.php index d9777e2867..fa3296d241 100644 --- a/includes/Setup.php +++ b/includes/Setup.php @@ -322,8 +322,7 @@ $wgContLang = new StubContLang; // Now that variant lists may be available... $wgRequest->interpolateTitle(); - -$wgUser = new StubUser; +$wgUser = $wgCommandLineMode ? new User : User::newFromSession(); $wgLang = new StubUserLang; $wgOut = new StubObject( 'wgOut', 'OutputPage' ); $wgParser = new StubObject( 'wgParser', $wgParserConf['class'], array( $wgParserConf ) ); diff --git a/includes/StubObject.php b/includes/StubObject.php index c93e3fca35..fe28f91c92 100644 --- a/includes/StubObject.php +++ b/includes/StubObject.php @@ -165,30 +165,3 @@ class StubUserLang extends StubObject { } } } - -/** - * 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; - } -}