Last modified: 2013-04-22 16:16:09 UTC
It seems when a user is loaded from session, but the UserLoadFromSession hook aborts the process (by settings $result to false), User::load() will just not do anything. In other words, when a hook aborts, the User private variables are not initialized, meaning $mId and $mName are still null rather than false. Because of this, MediaWiki thinks the user is logged in and has a blank username, causing an exception to be thrown when the personal URLs are generated in SkinTemplate::loadPersonalUrls(). This occurred using Git master. Steps to reproduce: 1. Add this function somewhere: function wfBugTest( $user, &$result ) { $result = false; return true; } 2. Add the function into the UserLoadFromSession hook. 3. Try to access the wiki. Expected Result: User is logged out no matter what. Actual Result: Exception is thrown (details below). MediaWiki internal error. Original exception: exception 'MWException' with message 'SkinTemplate::makeTalkUrlDetails given invalid pagename User:' in /var/www/site/wiki/includes/SkinTemplate.php:727 Stack trace: #0 /var/www/site/wiki/includes/SkinTemplate.php(654): SkinTemplate->makeTalkUrlDetails('User:') #1 /var/www/site/wiki/includes/SkinTemplate.php(455): SkinTemplate->buildPersonalUrls() #2 /var/www/site/wiki/includes/OutputPage.php(1998): SkinTemplate->outputPage() #3 /var/www/site/wiki/includes/Wiki.php(543): OutputPage->output() #4 /var/www/site/wiki/includes/Wiki.php(446): MediaWiki->main() #5 /var/www/site/wiki/index.php(58): MediaWiki->run() #6 {main} Exception caught inside exception handler: exception 'MWException' with message 'SkinTemplate::makeTalkUrlDetails given invalid pagename User:' in /var/www/site/wiki/includes/SkinTemplate.php:727 Stack trace: #0 /var/www/site/wiki/includes/SkinTemplate.php(654): SkinTemplate->makeTalkUrlDetails('User:') #1 /var/www/site/wiki/includes/SkinTemplate.php(455): SkinTemplate->buildPersonalUrls() #2 /var/www/site/wiki/includes/OutputPage.php(1998): SkinTemplate->outputPage() #3 /var/www/site/wiki/includes/Exception.php(227): OutputPage->output() #4 /var/www/site/wiki/includes/Exception.php(273): MWException->reportHTML() #5 /var/www/site/wiki/includes/Exception.php(624): MWException->report() #6 /var/www/site/wiki/includes/Exception.php(705): MWExceptionHandler::report(Object(MWException)) #7 /var/www/site/wiki/includes/Wiki.php(449): MWExceptionHandler::handle(Object(MWException)) #8 /var/www/site/wiki/index.php(58): MediaWiki->run() #9 {main}
Seems to be because, although User::loadFromSession() calls loadDefaults() almost any time it fails, the one time it doesn't call it is when the hook aborts.
https://gerrit.wikimedia.org/r/21546
[ Bug assigned to code submitter. Priority: normal. ]
Adding catrope as cc, as he reviewed previous login/session MediaWiki core bugs.
Merged in change linked above.