Last modified: 2013-06-20 10:52:02 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T51423, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 49423 - Translate throws exception from hook called from Language::isKnownLanguageTag() if code is invalid
Translate throws exception from hook called from Language::isKnownLanguageTag...
Status: RESOLVED FIXED
Product: MediaWiki
Classification: Unclassified
Internationalization (Other open bugs)
unspecified
All All
: Unprioritized minor (vote)
: ---
Assigned To: Niklas Laxström
https://test.wikipedia.org/wiki/Foo%2...
: i18n
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2013-06-11 03:25 UTC by PiRSquared17
Modified: 2013-06-20 10:52 UTC (History)
10 users (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments

Description PiRSquared17 2013-06-11 03:25:48 UTC
It should return false.

Note that the underlying error may be in Language::isKnownLanguageTag.

Here's a test page: https://test.wikipedia.org/wiki/Foo%27s_bar
And here's the module: https://test.wikipedia.org/wiki/Module:IsKnownLanguageTag

You can just test this with mw.language.isKnownLanguageTag("'") or something like that.

Obviously, it should return false -- it's not a known language code!
Comment 2 Brad Jorsch 2013-06-11 13:58:48 UTC
It appears to be due to the Translate extension, one of its hooks is throwing an exception. Reassigning accordingly.

Backtrace: (note the Translate extension hook call at #2)

2013-06-11 13:55:49 srv193 testwiki: [c959ea77] /wiki/Foo%27s_bar   Exception from line 217 of /usr/local/apache/common-local/php-1.22wmf6/languages/Language.php: Invalid language code "Foo's bar"
#0 /usr/local/apache/common-local/php-1.22wmf6/languages/Language.php(196): Language::newFromCode('Foo's bar')
#1 /usr/local/apache/common-local/php-1.22wmf6/includes/Message.php(381): Language::factory('Foo's bar')
#2 /usr/local/apache/common-local/php-1.22wmf6/extensions/Translate/TranslateHooks.php(254): Message->inLanguage('Foo's bar')
#3 [internal function]: TranslateHooks::translateMessageDocumentationLanguage(Array, 'Foo's bar')
#4 /usr/local/apache/common-local/php-1.22wmf6/includes/Hooks.php(196): call_user_func_array('TranslateHooks:...', Array)
#5 /usr/local/apache/common-local/php-1.22wmf6/includes/GlobalFunctions.php(3834): Hooks::run('LanguageGetTran...', Array)
#6 /usr/local/apache/common-local/php-1.22wmf6/languages/Language.php(867): wfRunHooks('LanguageGetTran...', Array)
#7 /usr/local/apache/common-local/php-1.22wmf6/languages/Language.php(912): Language::fetchLanguageNames('Foo's bar', 'all')
#8 /usr/local/apache/common-local/php-1.22wmf6/languages/Language.php(393): Language::fetchLanguageName('Foo's bar', 'Foo's bar')
#9 /usr/local/apache/common-local/php-1.22wmf6/extensions/Scribunto/engines/LuaCommon/LanguageLibrary.php(66): Language::isKnownLanguageTag('Foo's bar')
#10 [internal function]: Scribunto_LuaLanguageLibrary->isKnownLanguageTag('Foo's bar')
#11 /usr/local/apache/common-local/php-1.22wmf6/extensions/Scribunto/engines/LuaSandbox/Engine.php(237): call_user_func_array(Array, Array)
#12 [internal function]: Scribunto_LuaSandboxCallback->__call('isKnownLanguage...', Array)
#13 [internal function]: Scribunto_LuaSandboxCallback->isKnownLanguageTag('Foo's bar')
#14 [internal function]: LuaSandboxFunction->call(Object(LuaSandboxFunction))
#15 /usr/local/apache/common-local/php-1.22wmf6/extensions/Scribunto/engines/LuaSandbox/Engine.php(158): call_user_func_array(Array, Array)
#16 /usr/local/apache/common-local/php-1.22wmf6/extensions/Scribunto/engines/LuaCommon/LuaCommon.php(186): Scribunto_LuaSandboxInterpreter->callFunction(Object(LuaSandboxFunction), Object(LuaSandboxFunction))
#17 /usr/local/apache/common-local/php-1.22wmf6/extensions/Scribunto/engines/LuaCommon/LuaCommon.php(643): Scribunto_LuaEngine->executeFunctionChunk(Object(LuaSandboxFunction), Object(PPTemplateFrame_DOM))
#18 /usr/local/apache/common-local/php-1.22wmf6/extensions/Scribunto/common/Hooks.php(108): Scribunto_LuaModule->invoke('isKnownLanguage...', Object(PPTemplateFrame_DOM))
#19 [internal function]: ScribuntoHooks::invokeHook(Object(Parser), Object(PPFrame_DOM), Array)
#20 /usr/local/apache/common-local/php-1.22wmf6/includes/parser/Parser.php(3560): call_user_func_array('ScribuntoHooks:...', Array)
#21 /usr/local/apache/common-local/php-1.22wmf6/includes/parser/Parser.php(3278): Parser->callParserFunction(Object(PPFrame_DOM), '#invoke', Array)
#22 /usr/local/apache/common-local/php-1.22wmf6/includes/parser/Preprocessor_DOM.php(1085): Parser->braceSubstitution(Array, Object(PPFrame_DOM))
#23 /usr/local/apache/common-local/php-1.22wmf6/includes/parser/Parser.php(3101): PPFrame_DOM->expand(Object(PPNode_DOM), 0)
#24 /usr/local/apache/common-local/php-1.22wmf6/includes/parser/Parser.php(1157): Parser->replaceVariables('{{#invoke:isKno...')
#25 /usr/local/apache/common-local/php-1.22wmf6/includes/parser/Parser.php(386): Parser->internalParse('{{#invoke:isKno...')
#26 /usr/local/apache/common-local/php-1.22wmf6/includes/content/WikitextContent.php(300): Parser->parse('{{#invoke:isKno...', Object(Title), Object(ParserOptions), true, true, 174375)
#27 /usr/local/apache/common-local/php-1.22wmf6/includes/WikiPage.php(3424): WikitextContent->getParserOutput(Object(Title), 174375, Object(ParserOptions))
#28 /usr/local/apache/common-local/php-1.22wmf6/includes/PoolCounter.php(222): PoolWorkArticleView->doWork()
#29 /usr/local/apache/common-local/php-1.22wmf6/includes/Article.php(708): PoolCounterWork->execute()
#30 /usr/local/apache/common-local/php-1.22wmf6/includes/actions/ViewAction.php(44): Article->view()
#31 /usr/local/apache/common-local/php-1.22wmf6/includes/Wiki.php(439): ViewAction->show()
#32 /usr/local/apache/common-local/php-1.22wmf6/includes/Wiki.php(305): MediaWiki->performAction(Object(Article), Object(Title))
#33 /usr/local/apache/common-local/php-1.22wmf6/includes/Wiki.php(565): MediaWiki->performRequest()
#34 /usr/local/apache/common-local/php-1.22wmf6/includes/Wiki.php(458): MediaWiki->main()
#35 /usr/local/apache/common-local/php-1.22wmf6/index.php(55): MediaWiki->run()
#36 /usr/local/apache/common-local/w/index.php(3): require('/usr/local/apac...')
#37 {main}
Comment 3 Niklas Laxström 2013-06-11 14:03:17 UTC
Garbage in, garbage out.
Comment 4 Nemo 2013-06-11 14:12:45 UTC
To me, the (minor) problem here seems rather to be that an error in using a module/function shouldn't make the page explode in the user's face. I had to delete the failing template in order to be able to *save* an edit removing it.
Comment 5 Niklas Laxström 2013-06-11 14:29:33 UTC
I can fix this, but the fix will be in core.
Comment 6 Brad Jorsch 2013-06-11 14:40:57 UTC
(In reply to comment #3)
> Garbage in, garbage out.

Isn't the point of isKnownLanguageTag() for something to be able to determine whether the code is "garbage in"?
Comment 7 Gerrit Notification Bot 2013-06-11 16:42:56 UTC
Related URL: https://gerrit.wikimedia.org/r/68004 (Gerrit Change I3fd98ba08393856311a48fa40769027460c72ef9)
Comment 8 PiRSquared17 2013-06-11 18:53:03 UTC
(In reply to comment #6)
> (In reply to comment #3)
> > Garbage in, garbage out.
> 
> Isn't the point of isKnownLanguageTag() for something to be able to determine
> whether the code is "garbage in"?

That's exactly the point.
Comment 9 Niklas Laxström 2013-06-12 07:15:50 UTC
Yes, but the point was that it should not pass clearly invalid language codes to other parts of the system which expects valid language codes. See the patch.

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links