Page MenuHomePhabricator

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

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

Anomie created this task.Jul 7 2016, 9:12 PM
Restricted Application added subscribers: Zppix, Aklapper. · View Herald TranscriptJul 7 2016, 9:12 PM
Anomie updated the task description. (Show Details)Jul 12 2016, 1:52 PM

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

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

Catrope claimed this task.Jul 18 2016, 9:52 PM
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.

jmatazzoni closed this task as Resolved.Jul 20 2016, 8:57 PM
mmodell changed the subtype of this task from "Task" to "Production Error".Aug 28 2019, 11:11 PM