Page MenuHomePhabricator

WANObjectCache breaks extending $wgDefaultUserOptions via ExtensionFunctions in extensions.
Open, LowestPublic

Description

I found that when extensions (example: MultimediaViewer, Popups[WIP]) want to add new option inside $wgDefaultUserOptions they do that via ExtensionFunctions.
This usually works but on Vagrant setup from time to time $wgDefaultUserOptions does not have all options registered - it might cause Special:Preferences page to break (for new users when they didn't save preferences yet).

Reason:
CookieSessionProvider on line 119 calls UserInfo::newFromId() that tries to fetch user data. Sometimes when data is not cached it will try to build data calling User::loadOptions() and store user options in cache. Everything happens before calling ExtensionFunctions and because of that even extensions register new options in wgDefaultUserOptions those won't be visible for logged in user.

Stacktrace (call executed before calling ExtensionFunctions - one that prepopulates $user->getOptions()):

#0  User::getDefaultOptions() called at [/vagrant/mediawiki/includes/user/User.php:5138]
#1  User->loadOptions() called at [/vagrant/mediawiki/includes/user/User.php:482]
#2  User->{closure}(, 3600, Array ([lag] => 0,[since] => 1481771446.3097,[pending] => ), ) called at [/vagrant/mediawiki/includes/libs/objectcache/WANObjectCache.php:880]
#3  WANObjectCache->{closure}(, 3600, Array ([lag] => 0,[since] => 1481771446.3097,[pending] => ), )
#4  call_user_func_array(Closure Object (), Array ([0] => ,[1] => 3600,[2] => Array ([lag] => 0,[since] => 1481771446.3097,[pending] => ),[3] => )) called at [/vagrant/mediawiki/includes/libs/objectcache/WANObjectCache.php:997]
#5  WANObjectCache->doGetWithSetCallback(global:user:id:wiki:9, 3600, Closure Object (), Array ([pcTTL] => 30,[version] => 10), ) called at [/vagrant/mediawiki/includes/libs/objectcache/WANObjectCache.php:886]
#6  WANObjectCache->getWithSetCallback(global:user:id:wiki:9, 3600, Closure Object (), Array ([pcTTL] => 30,[version] => 10)) called at [/vagrant/mediawiki/includes/user/User.php:495]
#7  User->loadFromCache() called at [/vagrant/mediawiki/includes/user/User.php:436]
#8  User->loadFromId(0) called at [/vagrant/mediawiki/includes/user/User.php:400]
#9  User->load() called at [/vagrant/mediawiki/includes/session/UserInfo.php:88]
#10 MediaWiki\Session\UserInfo::newFromId(9) called at [/vagrant/mediawiki/includes/session/CookieSessionProvider.php:119]
#11 MediaWiki\Session\CookieSessionProvider->provideSessionInfo(WebRequest Object ([] => Array ([title] => Special:Preferences),[] => Array ([HOST] => php5.local.wmftest.net:8080,[CONNECTION] => keep-alive,[CACHE-CONTROL] => max-age=0,[UPGRADE-INSECURE-REQUESTS] => 1,[USER-AGENT] => Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.75 Safari/537.36,[ACCEPT] => text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8,[DNT] => 1,[REFERER] => http://php5.local.wmftest.net:8080/wiki/Special:CreateAccount,[ACCEPT-ENCODING] => gzip, deflate, sdch,[ACCEPT-LANGUAGE] => pl,en-US;q=0.8,en;q=0.6,[COOKIE] => wikimwuser-sessionId=24f60d8595841f3e; optin=beta; mf_testcookie=test_value; stopMobileRedirect=true; XDEBUG_SESSION=PHPSTORM; wiki_session=hc1favqr43n52jg6uhjci40uns4up96r; wikiUserID=9; wikiUserName=Test5),[] => ,[] => 10.0.2.2,[] => 1481771446.221,[] => ,[] => ,[] => )) called at [/vagrant/mediawiki/includes/session/SessionManager.php:486]
#12 MediaWiki\Session\SessionManager->getSessionInfoForRequest(WebRequest Object ([] => Array ([title] => Special:Preferences),[] => Array ([HOST] => php5.local.wmftest.net:8080,[CONNECTION] => keep-alive,[CACHE-CONTROL] => max-age=0,[UPGRADE-INSECURE-REQUESTS] => 1,[USER-AGENT] => Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.75 Safari/537.36,[ACCEPT] => text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8,[DNT] => 1,[REFERER] => http://php5.local.wmftest.net:8080/wiki/Special:CreateAccount,[ACCEPT-ENCODING] => gzip, deflate, sdch,[ACCEPT-LANGUAGE] => pl,en-US;q=0.8,en;q=0.6,[COOKIE] => wikimwuser-sessionId=24f60d8595841f3e; optin=beta; mf_testcookie=test_value; stopMobileRedirect=true; XDEBUG_SESSION=PHPSTORM; wiki_session=hc1favqr43n52jg6uhjci40uns4up96r; wikiUserID=9; wikiUserName=Test5),[] => ,[] => 10.0.2.2,[] => 1481771446.221,[] => ,[] => ,[] => )) called at [/vagrant/mediawiki/includes/session/SessionManager.php:189]
#13 MediaWiki\Session\SessionManager->getSessionForRequest(WebRequest Object ([] => Array ([title] => Special:Preferences),[] => Array ([HOST] => php5.local.wmftest.net:8080,[CONNECTION] => keep-alive,[CACHE-CONTROL] => max-age=0,[UPGRADE-INSECURE-REQUESTS] => 1,[USER-AGENT] => Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.75 Safari/537.36,[ACCEPT] => text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8,[DNT] => 1,[REFERER] => http://php5.local.wmftest.net:8080/wiki/Special:CreateAccount,[ACCEPT-ENCODING] => gzip, deflate, sdch,[ACCEPT-LANGUAGE] => pl,en-US;q=0.8,en;q=0.6,[COOKIE] => wikimwuser-sessionId=24f60d8595841f3e; optin=beta; mf_testcookie=test_value; stopMobileRedirect=true; XDEBUG_SESSION=PHPSTORM; wiki_session=hc1favqr43n52jg6uhjci40uns4up96r; wikiUserID=9; wikiUserName=Test5),[] => ,[] => 10.0.2.2,[] => 1481771446.221,[] => ,[] => ,[] => )) called at [/vagrant/mediawiki/includes/WebRequest.php:735]
#14 WebRequest->getSession() called at [/vagrant/mediawiki/includes/session/SessionManager.php:128]
#15 MediaWiki\Session\SessionManager::getGlobalSession() called at [/vagrant/mediawiki/includes/Setup.php:759]
#16 require_once(/vagrant/mediawiki/includes/Setup.php) called at [/vagrant/mediawiki/includes/WebStart.php:137]
#17 require(/vagrant/mediawiki/includes/WebStart.php) called at [/vagrant/mediawiki/index.php:42]
#18 require(/vagrant/mediawiki/index.php) called at [/var/www/w/index.php:5]

I experienced this issue when I was working on T146889. Everything works pretty well but when I'm spamming Special:Preferences page it breaks from time to time. As we want to store the default options in configuration I cannot use callback in extension.json because I cannot use ConfigFactory on that state.

Event Timeline

pmiazga created this task.Dec 15 2016, 3:17 AM
Restricted Application added a subscriber: Aklapper. · View Herald TranscriptDec 15 2016, 3:17 AM
phuedx renamed this task from WANObjectCache breaks exteding $wgDefaultUserOptions via ExtensionFunctions in extensions. to WANObjectCache breaks extending $wgDefaultUserOptions via ExtensionFunctions in extensions..Dec 15 2016, 8:49 AM
jhobs triaged this task as Normal priority.Dec 15 2016, 5:16 PM
jhobs edited projects, added MediaViewer, Readers-Web-Backlog; removed Multimedia.
jhobs moved this task from Incoming to Needs Prioritization on the Readers-Web-Backlog board.
ovasileva lowered the priority of this task from Normal to Low.Jan 26 2017, 4:25 PM
ovasileva moved this task from Needs Prioritization to 2014-15 Q4 on the Readers-Web-Backlog board.
ovasileva lowered the priority of this task from Low to Lowest.Feb 16 2017, 6:55 PM
ovasileva removed a project: Page-Previews.