Page MenuHomePhabricator

Avoid invoking Parser in WikibaseClient ResourceLoaderJqueryMsgModuleMagicWords hook
Closed, ResolvedPublic

Description

When generating the startup response for a wiki, ResourceLoader needs to compute the content and version of the mediawiki.jqueryMsg module. This currently involves invoking the Parser.

The Parser adds performance overhead that I believe may've been unintentional.

It is coming from WikibaseClient's ResourceLoaderJqueryMsgModuleMagicWords hook.

Flame graph:

Code:
https://gerrit.wikimedia.org/g/mediawiki/extensions/Wikibase/+/e46b4e97f3dc87612adde85d5b2a512c49629956/client/includes/Hooks/MagicWordHookHandlers.php#126

# function doResourceLoaderJqueryMsgModuleMagicWords {
$magicWords['WBREPONAME'] = $this->getRepoName( $lang );

# function getRepoName {
$message = new Message( $repoSiteName );
$message->inLanguage( $lang );
if ( $message->exists() ) {
	return $message->parse();

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald Transcript

I'd recommend considering Message::text() instead of Message::parse(). This would disallow templates and parser functions, which aren't currently used in those messages.

https://codesearch.wmflabs.org/search/?q=wikibase-repo-name.%2B%5B%5C%5B%5C%5D%7B%7D%27%3C%3E%5D&i=nope

Addshore triaged this task as Medium priority.Aug 17 2018, 3:05 PM

Change 453410 had a related patch set uploaded (by Addshore; owner: Addshore):
[mediawiki/extensions/Wikibase@master] Don't parse i18n message for WBREPONAME magic word

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

Change 453410 merged by jenkins-bot:
[mediawiki/extensions/Wikibase@master] Don't parse i18n message for WBREPONAME magic word

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

Addshore moved this task from Active 🚁 to Closing ✔️ on the User-Addshore board.
Addshore moved this task from incoming to in progress on the Wikidata board.
Addshore moved this task from Peer Review to Done on the Wikidata-Campsite board.