Page MenuHomePhabricator

[GrowthExperiments] Sessions are disabled for this entry point
Closed, ResolvedPublic

Description

Error

Request URL: https://ko.wikipedia.org/w/load.php?lang=ko&modules=startup&only=scripts&skin=vector
Request ID: XOaiBwpAME0AACDCUMcAAAAP

Note that there are other extensions triggering a similar errors.

message
/srv/mediawiki/php-1.34.0-wmf.6/includes/session/SessionManager.php:826
Sessions are disabled for this entry point
trace
#0 /srv/mediawiki/php-1.34.0-wmf.6/includes/session/SessionManager.php(310): MediaWiki\Session\SessionManager->getSessionFromInfo(MediaWiki\Session\SessionInfo, WebRequest)
#1 /srv/mediawiki/php-1.34.0-wmf.6/includes/session/SessionManager.php(244): MediaWiki\Session\SessionManager->getEmptySessionInternal(WebRequest)
#2 /srv/mediawiki/php-1.34.0-wmf.6/includes/session/SessionManager.php(194): MediaWiki\Session\SessionManager->getEmptySession(WebRequest)
#3 /srv/mediawiki/php-1.34.0-wmf.6/includes/WebRequest.php(758): MediaWiki\Session\SessionManager->getSessionForRequest(WebRequest)
#4 /srv/mediawiki/php-1.34.0-wmf.6/includes/user/User.php(1354): WebRequest->getSession()
#5 /srv/mediawiki/php-1.34.0-wmf.6/includes/user/User.php(446): User->loadFromSession()
#6 /srv/mediawiki/php-1.34.0-wmf.6/includes/user/User.php(5288): User->load()
#7 /srv/mediawiki/php-1.34.0-wmf.6/includes/user/User.php(3031): User->loadOptions()
#8 /srv/mediawiki/php-1.34.0-wmf.6/includes/context/RequestContext.php(336): User->getOption(string)
#9 /srv/mediawiki/php-1.34.0-wmf.6/includes/StubUserLang.php(52): RequestContext->getLanguage()
#10 /srv/mediawiki/php-1.34.0-wmf.6/includes/StubObject.php(168): StubUserLang->_newObject()
#11 /srv/mediawiki/php-1.34.0-wmf.6/includes/StubObject.php(95): StubObject->_unstub(string, integer)
#12 /srv/mediawiki/php-1.34.0-wmf.6/includes/content/ContentHandler.php(696): StubObject::unstub(StubUserLang)
#13 /srv/mediawiki/php-1.34.0-wmf.6/includes/Title.php(4511): ContentHandler->getPageLanguage(Title)
#14 /srv/mediawiki/php-1.34.0-wmf.6/includes/parser/Parser.php(940): Title->getPageLanguage()
#15 /srv/mediawiki/php-1.34.0-wmf.6/includes/parser/Parser.php(3282): Parser->getTargetLanguage()
#16 /srv/mediawiki/php-1.34.0-wmf.6/includes/parser/PPFrame_Hash.php(254): Parser->braceSubstitution(array, PPFrame_Hash)
#17 /srv/mediawiki/php-1.34.0-wmf.6/includes/parser/Parser.php(3050): PPFrame_Hash->expand(PPNode_Hash_Tree, integer)
#18 /srv/mediawiki/php-1.34.0-wmf.6/includes/parser/Parser.php(749): Parser->replaceVariables(string, PPFrame_Hash)
#19 /srv/mediawiki/php-1.34.0-wmf.6/includes/parser/Parser.php(4830): Parser->preprocess(string, NULL, ParserOptions)
#20 /srv/mediawiki/php-1.34.0-wmf.6/includes/cache/MessageCache.php(1193): Parser->transformMsg(string, ParserOptions, NULL)
#21 /srv/mediawiki/php-1.34.0-wmf.6/extensions/GrowthExperiments/includes/HelpPanel.php(175): MessageCache->transform(string)
#22 /srv/mediawiki/php-1.34.0-wmf.6/extensions/GrowthExperiments/includes/HelpPanelHooks.php(107): GrowthExperiments\HelpPanel::getHelpDeskTitle(GlobalVarConfig)
#23 /srv/mediawiki/php-1.34.0-wmf.6/includes/resourceloader/ResourceLoaderFileModule.php(1122): GrowthExperiments\HelpPanelHooks::getModuleData(ResourceLoaderContext)
#24 /srv/mediawiki/php-1.34.0-wmf.6/includes/resourceloader/ResourceLoaderFileModule.php(624): ResourceLoaderFileModule->expandPackageFiles(ResourceLoaderContext)
#25 /srv/mediawiki/php-1.34.0-wmf.6/includes/resourceloader/ResourceLoaderModule.php(833): ResourceLoaderFileModule->getDefinitionSummary(ResourceLoaderContext)
#26 /srv/mediawiki/php-1.34.0-wmf.6/includes/resourceloader/ResourceLoaderStartUpModule.php(245): ResourceLoaderModule->getVersionHash(ResourceLoaderContext)
#27 /srv/mediawiki/php-1.34.0-wmf.6/includes/resourceloader/ResourceLoaderStartUpModule.php(405): ResourceLoaderStartUpModule->getModuleRegistrations(ResourceLoaderContext)
#28 /srv/mediawiki/php-1.34.0-wmf.6/includes/resourceloader/ResourceLoaderModule.php(727): ResourceLoaderStartUpModule->getScript(ResourceLoaderContext)
#29 /srv/mediawiki/php-1.34.0-wmf.6/includes/resourceloader/ResourceLoaderModule.php(694): ResourceLoaderModule->buildContent(ResourceLoaderContext)
#30 /srv/mediawiki/php-1.34.0-wmf.6/includes/resourceloader/ResourceLoaderModule.php(830): ResourceLoaderModule->getModuleContent(ResourceLoaderContext)
#31 /srv/mediawiki/php-1.34.0-wmf.6/includes/resourceloader/ResourceLoader.php(648): ResourceLoaderModule->getVersionHash(ResourceLoaderContext)
#32 [internal function]: ResourceLoader->{closure}(string)
#33 /srv/mediawiki/php-1.34.0-wmf.6/includes/resourceloader/ResourceLoader.php(660): array_map(Closure, array)
#34 /srv/mediawiki/php-1.34.0-wmf.6/includes/resourceloader/ResourceLoader.php(741): ResourceLoader->getCombinedVersion(ResourceLoaderContext, array)
#35 /srv/mediawiki/php-1.34.0-wmf.6/load.php(46): ResourceLoader->respond(ResourceLoaderContext)
#36 /srv/mediawiki/w/load.php(3): require(string)
#37 {main}

And a similar one for mobile. There are slight differences since that one got served by php7.2 while the other got served by hhvm.

Request URL: https://ko.wikipedia.org/w/load.php?lang=ko&modules=startup&only=scripts&safemode=1&skin=minerva&target=mobile
Request ID: XOakBApAICAAACW

trace
#0 /srv/mediawiki/php-1.34.0-wmf.6/includes/session/SessionManager.php(196): MediaWiki\Session\SessionManager->getSessionFromInfo(MediaWiki\Session\SessionInfo, WebRequest)
#1 /srv/mediawiki/php-1.34.0-wmf.6/includes/WebRequest.php(758): MediaWiki\Session\SessionManager->getSessionForRequest(WebRequest)
#2 /srv/mediawiki/php-1.34.0-wmf.6/includes/user/User.php(1354): WebRequest->getSession()
#3 /srv/mediawiki/php-1.34.0-wmf.6/includes/user/User.php(446): User->loadFromSession()
#4 /srv/mediawiki/php-1.34.0-wmf.6/includes/user/User.php(5288): User->load()
#5 /srv/mediawiki/php-1.34.0-wmf.6/includes/user/User.php(3031): User->loadOptions()
#6 /srv/mediawiki/php-1.34.0-wmf.6/includes/context/RequestContext.php(336): User->getOption(string)
#7 /srv/mediawiki/php-1.34.0-wmf.6/includes/StubUserLang.php(52): RequestContext->getLanguage()
#8 /srv/mediawiki/php-1.34.0-wmf.6/includes/StubObject.php(168): StubUserLang->_newObject()
#9 /srv/mediawiki/php-1.34.0-wmf.6/includes/StubObject.php(95): StubObject->_unstub(string, integer)
#10 /srv/mediawiki/php-1.34.0-wmf.6/includes/content/ContentHandler.php(696): StubObject::unstub(StubUserLang)
#11 /srv/mediawiki/php-1.34.0-wmf.6/includes/Title.php(4511): ContentHandler->getPageLanguage(Title)
#12 /srv/mediawiki/php-1.34.0-wmf.6/includes/parser/Parser.php(940): Title->getPageLanguage()
#13 /srv/mediawiki/php-1.34.0-wmf.6/includes/parser/Parser.php(3282): Parser->getTargetLanguage()
#14 /srv/mediawiki/php-1.34.0-wmf.6/includes/parser/PPFrame_Hash.php(254): Parser->braceSubstitution(array, PPFrame_Hash)
#15 /srv/mediawiki/php-1.34.0-wmf.6/includes/parser/Parser.php(3050): PPFrame_Hash->expand(PPNode_Hash_Tree, integer)
#16 /srv/mediawiki/php-1.34.0-wmf.6/includes/parser/Parser.php(749): Parser->replaceVariables(string, PPFrame_Hash)
#17 /srv/mediawiki/php-1.34.0-wmf.6/includes/parser/Parser.php(4830): Parser->preprocess(string, NULL, ParserOptions)
#18 /srv/mediawiki/php-1.34.0-wmf.6/includes/cache/MessageCache.php(1193): Parser->transformMsg(string, ParserOptions, NULL)
#19 /srv/mediawiki/php-1.34.0-wmf.6/extensions/GrowthExperiments/includes/HelpPanel.php(177): MessageCache->transform(string)
#20 /srv/mediawiki/php-1.34.0-wmf.6/extensions/GrowthExperiments/includes/HelpPanelHooks.php(107): GrowthExperiments\HelpPanel::getHelpDeskTitle(GlobalVarConfig)
#21 /srv/mediawiki/php-1.34.0-wmf.6/includes/resourceloader/ResourceLoaderFileModule.php(1122): GrowthExperiments\HelpPanelHooks::getModuleData(ResourceLoaderContext)
#22 /srv/mediawiki/php-1.34.0-wmf.6/includes/resourceloader/ResourceLoaderFileModule.php(624): ResourceLoaderFileModule->expandPackageFiles(ResourceLoaderContext)
#23 /srv/mediawiki/php-1.34.0-wmf.6/includes/resourceloader/ResourceLoaderModule.php(833): ResourceLoaderFileModule->getDefinitionSummary(ResourceLoaderContext)
#24 /srv/mediawiki/php-1.34.0-wmf.6/includes/resourceloader/ResourceLoaderStartUpModule.php(245): ResourceLoaderModule->getVersionHash(ResourceLoaderContext)
#25 /srv/mediawiki/php-1.34.0-wmf.6/includes/resourceloader/ResourceLoaderStartUpModule.php(405): ResourceLoaderStartUpModule->getModuleRegistrations(ResourceLoaderContext)
#26 /srv/mediawiki/php-1.34.0-wmf.6/includes/resourceloader/ResourceLoaderModule.php(727): ResourceLoaderStartUpModule->getScript(ResourceLoaderContext)
#27 /srv/mediawiki/php-1.34.0-wmf.6/includes/resourceloader/ResourceLoaderModule.php(694): ResourceLoaderModule->buildContent(ResourceLoaderContext)
#28 /srv/mediawiki/php-1.34.0-wmf.6/includes/resourceloader/ResourceLoaderModule.php(830): ResourceLoaderModule->getModuleContent(ResourceLoaderContext)
#29 /srv/mediawiki/php-1.34.0-wmf.6/includes/resourceloader/ResourceLoader.php(648): ResourceLoaderModule->getVersionHash(ResourceLoaderContext)
#30 [internal function]: Closure$ResourceLoader::getCombinedVersion(string)
#31 /srv/mediawiki/php-1.34.0-wmf.6/includes/resourceloader/ResourceLoader.php(660): array_map(Closure$ResourceLoader::getCombinedVersion;1625, array)
#32 /srv/mediawiki/php-1.34.0-wmf.6/includes/resourceloader/ResourceLoader.php(741): ResourceLoader->getCombinedVersion(ResourceLoaderContext, array)
#33 /srv/mediawiki/php-1.34.0-wmf.6/load.php(46): ResourceLoader->respond(ResourceLoaderContext)
#34 /srv/mediawiki/w/load.php(3): include(string)
#35 {main}

Impact

With the help panel preference on, if my default editor is VE, clicking "Edit" does nothing.
If I go to a page where there is no VE (like a talk page), clicking "Edit source" opens an editor that works, but no toolbar:


and neither situation have the help panel button.

On the homepage, the mentorship module button takes me to a source editor to add a section on the mentor talk page, and the help module button takes me to the help desk.

Notes

Details

Related Gerrit Patches:
mediawiki/extensions/GrowthExperiments : wmf/1.34.0-wmf.7Prevent parsing of GEHelpPanelHelpDeskTitle from accessing the session
mediawiki/extensions/GrowthExperiments : wmf/1.34.0-wmf.6Prevent parsing of GEHelpPanelHelpDeskTitle from accessing the session
operations/mediawiki-config : masterHardcode korean help desk config
mediawiki/extensions/GrowthExperiments : masterPrevent parsing of GEHelpPanelHelpDeskTitle from accessing the session

Event Timeline

hashar created this task.May 23 2019, 1:47 PM
Restricted Application added subscribers: revi, Aklapper. · View Herald TranscriptMay 23 2019, 1:47 PM
hashar updated the task description. (Show Details)May 23 2019, 1:59 PM

Apparently the exception bubbles up and cause a message of: Calculating version for "ext.growthExperiments.Help" failed: BadMethodCallException: Sessions are disabled for this entry point

hashar added a subscriber: SBisson.May 23 2019, 2:15 PM

That seems to be the feature https://www.mediawiki.org/wiki/Growth/Focus_on_help_desk/Help_panel Apparently that only happens on the kowiki. There is no specific referrer URL to blame :/

SBisson triaged this task as Unbreak Now! priority.May 23 2019, 2:36 PM

kowiki is using a parser function in its help desk config: 위키백과:질문방/{{Y-M|0}} Their help desk has a collection of subpages, one for each year-month.

I can spot no changes around that in the GrowthExperiments extension in a while but a change to Core may create an unexpected interaction.

As far as I can tell in my testing, having the Help Panel enabled currently breaks the edit button. Clicking on it sends an error to the console and the page stays in view mode.

Also, asking questions from the Homepage (Help or Mentorship modules) is equally broken. Clicking the "ask question" buttons navigates to the pages where the questions would be posted, which is the no-js behavior.

Restricted Application added a subscriber: Liuxinyu970226. · View Herald TranscriptMay 23 2019, 2:36 PM

@revi It looks like the Help panel and Homepage are currently broken on kowiki. See comments above for details.

We could disable them in the short term or change the help desk config from 위키백과:질문방/{{Y-M|0}} to the exact value for this month (is it 위키백과:질문방/2019년_5월 ?) while we investigate further.

Can you confirm that these are indeed broken for you and what is the title for the help desk for May 2019?

Thanks

MMiller_WMF updated the task description. (Show Details)May 23 2019, 3:14 PM

Change 512186 had a related patch set uploaded (by Sbisson; owner: Sbisson):
[operations/mediawiki-config@master] Hardcode korean help desk config

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

Change 512186 merged by jenkins-bot:
[operations/mediawiki-config@master] Hardcode korean help desk config

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

Mentioned in SAL (#wikimedia-operations) [2019-05-23T15:31:37Z] <hashar@deploy1001> Synchronized wmf-config/InitialiseSettings.php: Hardcode korean help desk config - T224224 (duration: 00m 48s)

hashar lowered the priority of this task from Unbreak Now! to High.May 23 2019, 3:35 PM

Changing priority, that has been worked for now. Still have to figure out the root cause though :-(

After digging through the stack trace, rMW855b1794b6b7: Unstub $wgLang for PageContentLanguage hook looks likely to have caused this. It's #12 in the first stack trace and #10 in the second.

The korean help desk is currently hardcoded and will become invalid in June.

We have a test for using a parser function in the help desk config but it doesn't check that it's independent from the session and can be called from a data module. Maybe it's the data module that needs a test...

SBisson claimed this task.May 23 2019, 5:31 PM

After digging through the stack trace, rMW855b1794b6b7: Unstub $wgLang for PageContentLanguage hook looks likely to have caused this. It's #12 in the first stack trace and #10 in the second.

Right, that's indeed the cause. Unstubing $wgLang calls RequestContext::getMain()->getLanguage(), which is forbidden in a RL data module.

To give a bit more context into what we're trying to do, we're calling MessageCache::singleton()->transform( "HelpDesk/{{Y-M|0}}" ) to execute the Y-M template. I implied it was a parser function is previous comments but I was mistaken: it's a template defined on kowiki that basically returns the current year and month. It is convenient for us to use this template as it ensures that all links to the help desk (on wiki and in the GrowthExperiments extension) are generated with the same tool and always in sync.

I guess one question I have is... duh, patch coming. It turns out MessageCache::singleton()->transform() accepts a Language object as its 3rd parameter. Providing it bypasses this whole unstubing business.

@Krinkle any idea how to test that a function is safe to use in a RL data module, in the sense that it doesn't read the session? I've tried adding define('MW_NO_SESSION', 1); in the test case but it doesn't seem to do it.

Change 512209 had a related patch set uploaded (by Sbisson; owner: Sbisson):
[mediawiki/extensions/GrowthExperiments@master] [WIP] Prevent parsing of GEHelpPanelHelpDeskTitle from accessing the session

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

Here be dragons indeed. It's very hard to know what will eventually rely on a session. For example I have seen the same error in ResourceLoaderProjectIconsModule which works fine, until a file it references is not found, in which case code deep in the trace is trying to generate error messages... in user language.

In this case any hook which would have caused the $userLang parameter to unstub would have caused this. It just happens always and consistently now.

Here be dragons indeed. It's very hard to know what will eventually rely on a session. For example I have seen the same error in ResourceLoaderProjectIconsModule which works fine, until a file it references is not found, in which case code deep in the trace is trying to generate error messages... in user language.
In this case any hook which would have caused the $userLang parameter to unstub would have caused this. It just happens always and consistently now.

Perhaps it would make sense to just set $wgLang = $wgContLang in contexts with no session. The RequestContext could know about this.

Krinkle updated the task description. (Show Details)May 24 2019, 1:32 PM

I guess one question I have is... duh, patch coming. It turns out MessageCache::singleton()->transform() accepts a Language object as its 3rd parameter. Providing it bypasses this whole unstubing business.

Yep, the ResourceLoaderContext object provides the language to use for this, based on the incoming stateless request.

It also has a msg() method that already has this set up. Methods such as wfMessage and msg() methods from other objects must not be used in ResourceLoader context.

I would also generally advise against use of something has low-level as MessageCache directly in "regular" code. You'll probably want to use RawMessage instead of this purpose, and then chain accordingly with ->inLanguage( $ctx->getLanguage() ) and ->text().

I would also generally advise against use of something has low-level as MessageCache directly in "regular" code. You'll probably want to use RawMessage instead of this purpose, and then chain accordingly with ->inLanguage( $ctx->getLanguage() ) and ->text().

Yeah, forcing the language is the key here but also good call on RawMessage, it makes the code simpler.

I would still like to write a high level integration test to make sure the module is and stays independent from the session. Something along the lines of

  1. Register module with 'packageFiles' => [ 'name' => 'data', 'callback' => <function here> ]
  2. Load the module in such a way that it would fail if it tried to access the session

Any pointers for this? Also, is it something that RL itself could test in CI that all loaded extensions have only valid modules? Just like we test that all messages are documented and all API params have valid documentation messages.

I suppose a way to disable RequestContext::getMain() would suffice. I don't know off-hand a way to make that throw in PHPUnit context. I know that for services we have $services->disableService() for this purpose, but RequestContext::getMain isn't (yet) stored in ServiceWiring.

If it were stored there instead, with getMain() as short cut to $services->getMainRequestContext(), then we could disable it this way for specific tests.

Change 512209 merged by jenkins-bot:
[mediawiki/extensions/GrowthExperiments@master] Prevent parsing of GEHelpPanelHelpDeskTitle from accessing the session

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

Change 512940 had a related patch set uploaded (by Sbisson; owner: Sbisson):
[mediawiki/extensions/GrowthExperiments@wmf/1.34.0-wmf.6] Prevent parsing of GEHelpPanelHelpDeskTitle from accessing the session

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

Change 512941 had a related patch set uploaded (by Sbisson; owner: Sbisson):
[mediawiki/extensions/GrowthExperiments@wmf/1.34.0-wmf.7] Prevent parsing of GEHelpPanelHelpDeskTitle from accessing the session

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

Change 512940 merged by jenkins-bot:
[mediawiki/extensions/GrowthExperiments@wmf/1.34.0-wmf.6] Prevent parsing of GEHelpPanelHelpDeskTitle from accessing the session

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

Change 512941 merged by jenkins-bot:
[mediawiki/extensions/GrowthExperiments@wmf/1.34.0-wmf.7] Prevent parsing of GEHelpPanelHelpDeskTitle from accessing the session

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

@revi The real fix is now in production and the config hack was reverted. Let us know if you notice any issue.

revi added a comment.May 29 2019, 5:00 PM

ACK, just in time as June is coming! xD

Etonkovidova closed this task as Resolved.Jun 3 2019, 2:47 PM

Checked in kowiki (wmf.7 after 6/01/2019.

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