Page MenuHomePhabricator

new User() objects see undefined $wgContLang due to early call of loadfromsession() in Setup.php
Closed, ResolvedPublic

Description

I think, but I am not fully sure, to have found a problem in setup.php which
could lead to undefined $wgContLang object under certain circumstances; pls.
correct me if I'm wrong.

The following part in setup.php can call User:loadFromSession() -- which can(!)
create a new User() w/o going via SpecialUserLogin -- without the proper or
provisional language settings, which leads to $wgContLang being undefined and to
some undefined user account settings.

I noticed this behaviour while playing with AuthPlugin.php, Auth->InitUser(),
User->InitUser and User->loadfromsession().

if( $wgCommandLineMode ) {

  1. Used for some maintenance scripts; user session cookies can screw things up
  2. when the database is in an in-between state.

$wgUser = new User();
} else {
$wgUser = User::loadFromSession();
}

I propose to move these lines in setup.php just a couple of lines below: AFTER
the language setting
This can be seen in attachment
http://bugzilla.wikimedia.org/attachment.cgi?id=398 [for
http://bugzilla.wikipedia.org/show_bug.cgi?id=1360 ] or here:

@@ -290,6 +291,14 @@
$wgContLang = setupLangObj( $wgContLangClass );
$wgContLang->initEncoding();

+if( $wgCommandLineMode ) {
+ # Used for some maintenance scripts; user session cookies can screw things up
+ # when the database is in an in-between state.
+ $wgUser = new User();
+} else {
+ $wgUser = User::loadFromSession();
+}
+


Version: 1.4.x
Severity: normal

Details

Reference
bz1805

Event Timeline

bzimport raised the priority of this task from to High.Nov 21 2014, 8:20 PM
bzimport set Reference to bz1805.
bzimport added a subscriber: Unknown Object (MLST).
Wikinaut created this task.Apr 2 2005, 10:17 PM
brion added a comment.Jun 16 2005, 7:53 AM

Removing from 1.5 blockers as nothing in 1.5 should actually be affected by it; the language
object is only hit for default settings for anon users, and there was a hackaround for that which
worked already.

Moving to code quality (bug 700) instead, and resolving as FIXED for 1.5 in CVS HEAD.

Also reported as http://bugzilla.wikimedia.org/show_bug.cgi?id=3426 Variable
wgContLang is null in ObjectCache.php and Title.php. Not sure, whether it is a
real duplicate.