Page MenuHomePhabricator

"User::loadFromSession called before the end of Setup.php" warning due to Echo
Closed, ResolvedPublicPRODUCTION ERROR

Description

Something deep inside Echo is using a Message object with the default $wgLang language despite being called during account auto-creation when $wgUser and $wgLang is not yet available.

Stack trace:

/srv/mediawiki/php-1.28.0-wmf.9/includes/user/User.php:5305
/srv/mediawiki/php-1.28.0-wmf.9/includes/user/User.php:2876
/srv/mediawiki/php-1.28.0-wmf.9/includes/context/RequestContext.php:363
/srv/mediawiki/php-1.28.0-wmf.9/includes/Message.php:364
/srv/mediawiki/php-1.28.0-wmf.9/includes/Message.php:1182
/srv/mediawiki/php-1.28.0-wmf.9/includes/Message.php:944
/srv/mediawiki/php-1.28.0-wmf.9/extensions/Echo/includes/ForeignNotifications.php:227
/srv/mediawiki/php-1.28.0-wmf.9/extensions/Echo/includes/ForeignNotifications.php:207
/srv/mediawiki/php-1.28.0-wmf.9/extensions/Echo/includes/ForeignWikiRequest.php:48
/srv/mediawiki/php-1.28.0-wmf.9/extensions/Echo/includes/ForeignWikiRequest.php:25
/srv/mediawiki/php-1.28.0-wmf.9/extensions/Echo/includes/NotifUser.php:710
/srv/mediawiki/php-1.28.0-wmf.9/extensions/Echo/includes/NotifUser.php:741
/srv/mediawiki/php-1.28.0-wmf.9/extensions/Echo/includes/NotifUser.php:488
/srv/mediawiki/php-1.28.0-wmf.9/extensions/Echo/Hooks.php:1147
/srv/mediawiki/php-1.28.0-wmf.9/includes/Hooks.php:195
/srv/mediawiki/php-1.28.0-wmf.9/includes/user/User.php:3952
/srv/mediawiki/php-1.28.0-wmf.9/includes/auth/AuthManager.php:1678
/srv/mediawiki/php-1.28.0-wmf.9/includes/Setup.php:861
/srv/mediawiki/php-1.28.0-wmf.9/includes/WebStart.php:137
/srv/mediawiki/php-1.28.0-wmf.9/index.php:40
/srv/mediawiki/w/index.php:3

Options to resolve this include:

  • Don't even run the hook when called during account autocreation (I suspect it's not necessary there).
  • Don't load messages in this code path (you don't seem to be actually using the result).
  • Test $wgUser->isSafeToLoad(), and when false use ->inLanguage() to set the Message's language to $wgContLang or some other constant.

Event Timeline

Change 299673 had a related patch set uploaded (by Catrope):
ForeignWikiRequest: Also check User::isSafeToLoad()

https://gerrit.wikimedia.org/r/299673

Catrope moved this task from Untriaged to Needs Review on the Collab-Team-Q1-July-Sep-2016 board.

My patch avoids going into this code path at all if $wgUser->isSafeToLoad() is false.

Change 299673 merged by jenkins-bot:
ForeignWikiRequest: Also check User::isSafeToLoad()

https://gerrit.wikimedia.org/r/299673

Checked user auto-creation in betalabs - no problems found.

mmodell changed the subtype of this task from "Task" to "Production Error".Aug 28 2019, 11:11 PM