From 985e8971c8ceede96feb8e4e30a79ddf32109eb6 Mon Sep 17 00:00:00 2001 From: Chad Horohoe Date: Thu, 12 Aug 2010 17:10:00 +0000 Subject: [PATCH] =?utf8?q?Get=20rid=20of=20StubUser.=20Constructing=20a=20?= =?utf8?q?user=20object=20isn't=20quite=20as=20intensive=20as=20it=20once?= =?utf8?q?=20was.=20It=20actually=20takes=20more=20time=20using=20the=20St?= =?utf8?q?ubUser=20(construction=20+=20unstub=20on=20first=20call)=20than?= =?utf8?q?=20just=20initializing=20User::newFromSession()=20from=20the=20s?= =?utf8?q?tart.=20Either=20way,=20the=20real=20overhead=20starts=20when=20?= =?utf8?q?you=20start=20calling=20methods=20(for=20the=20nitpicky,=20the?= =?utf8?q?=20optimization=20was=20only=20about=2020=C2=B5s.=20The=20real?= =?utf8?q?=20gain=20here=20was=20eliminating=20a=20StubObject)?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- includes/AutoLoader.php | 1 - includes/Setup.php | 3 +-- includes/StubObject.php | 27 --------------------------- 3 files changed, 1 insertion(+), 30 deletions(-) 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; - } -} -- 2.20.1