Page MenuHomePhabricator

ResourceLoader: Internal error when calling with load.php with invalid uselang
Closed, ResolvedPublic

Description

Not a high priority since this is only relevant to requests that are invalid and are never formed by MediaWiki itself, but an ugly way to handle the error.

When accessing index.php with an invalid uselang, it gets sanitised to 'en' by Wiki.php -> RequestContext.php#sanitizeLangCode.

On the load.php path, it results in an MWException from Language::newFromCode

exception 'MWException' with message 'Invalid language code "x:' in mediawiki/languages/Language.php:217
Stack trace:
#0 mediawiki/languages/Language.php(196): Language::newFromCode('x:')
#1 mediawiki/includes/resourceloader/ResourceLoaderContext.php(162): Language::factory('x:')
#2 mediawiki/includes/resourceloader/ResourceLoaderContext.php(237): ResourceLoaderContext->getDirection()
#3 mediawiki/includes/resourceloader/ResourceLoaderWikiModule.php(224): ResourceLoaderContext->getHash()
#4 mediawiki/includes/resourceloader/ResourceLoaderWikiModule.php(179): ResourceLoaderWikiModule->getTitleMtimes(Object(ResourceLoaderContext))
#5 mediawiki/includes/resourceloader/ResourceLoader.php(514): ResourceLoaderWikiModule->getModifiedTime(Object(ResourceLoaderContext))
#6 mediawiki/load.php(43): ResourceLoader->respond(Object(ResourceLoaderContext))
#7 {main}

ResourceLoader::makeModuleResponse: generating module package failed: exception 'MWException' with message 'Invalid language code "x:"' in /usr/local/apache/common-local/php-1.23wmf17/languages/Language.php:217
Stack trace:
#0 /usr/local/apache/common-local/php-1.23wmf17/languages/Language.php(196): Language::newFromCode('x:')
#1 /usr/local/apache/common-local/php-1.23wmf17/includes/resourceloader/ResourceLoaderContext.php(162): Language::factory('x:')
#2 /usr/local/apache/common-local/php-1.23wmf17/includes/resourceloader/ResourceLoaderModule.php(118): ResourceLoaderContext->getDirection()
#3 /usr/local/apache/common-local/php-1.23wmf17/includes/resourceloader/ResourceLoaderWikiModule.php(158): ResourceLoaderModule->getFlip(Object(ResourceLoaderContext))
#4 /usr/local/apache/common-local/php-1.23wmf17/includes/resourceloader/ResourceLoader.php(778): ResourceLoaderWikiModule->getStyles(Object(ResourceLoaderContext))
#5 /usr/local/apache/common-local/php-1.23wmf17/includes/resourceloader/ResourceLoader.php(518): ResourceLoader->makeModuleResponse(Object(ResourceLoaderContext), Array, Array)
#6 /usr/local/apache/common-local/php-1.23wmf17/load.php(43): ResourceLoader->respond(Object(ResourceLoaderContext))
#7 /usr/local/apache/common-local/w/load.php(3): require('/usr/local/apac...')
#8 {main}


Version: unspecified
Severity: trivial

Details

Reference
bz62849

Event Timeline

bzimport raised the priority of this task from to Normal.
bzimport set Reference to bz62849.
Krinkle created this task.Mar 19 2014, 9:26 PM

Change 119644 had a related patch set uploaded by Krinkle:
resourceloader: Sanitize lang code before creating Language object

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

Change 119644 merged by jenkins-bot:
resourceloader: Sanitize lang code before creating Language object

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

(In reply to Gerrit Notification Bot from comment #2)

Change 119644 merged by jenkins-bot:

resourceloader: Sanitize lang code

before creating Language object

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

Status Merged