MessageCache::parse cause the following queries, both returning an empty resultset:
It would be nice if someone would fill in the connection that gets from MessageCache::parse() to Wikibase\Lib\Store\SiteLinkTable::getItemIdForLink(). Is it some parser hook that runs for every parse or something?
There seems to be a LuaSandbox bug that caused a multiplication factor into this bug and warrants further investigation.
After investigation, I see no evidence of this beyond the asserted fact that they come from use of MessageCache::parse(). You could as well lay the blame on Parsoid making lots of expandtemplate calls that lead to errors being reported from Scribunto.
Both "API" and "Dwimmerlaik" seem to be placeholders for "ghost titles" (as the comment in the code suggests). Those two placeholders, however, cause database queries that are probably redundant and possibly harmful.
Various parts of MediaWiki will throw exceptions if no title is set, because all index.php hits besides some early hooks are going to have a title, while api.php calls might not but still needs to call code that is going to blow up because it assumes $wgTitle or RequestContext::getMain()->getTitle() is set. The specific dummy titles used can be changed easily enough, but any title is going to "cause database queries that are probably redundant and possibly harmful". It would probably be better to figure out what caused all these database queries than to focus too much effort on "OMG dummy titles".
BTW, other "dummy" titles include "Main page" (possibly localized), "Special:Badtitle" (if the user lacks the 'read' right or in certain other situations), "AJAX" (via deprecated index.php?action=ajax), "LiquidThreads has a bug" (may be obsolete now that api.php sets a dummy title), "Special:AbuseFilter" (for AF hooks called from Setup.php), and any special page's title when special page transclusion is used.
A user-triggered Lua error should not cause a globaltitlefail.log warning and two redundant queries.
For the globaltitlefail.log, the needed fix is probably to have wfMessage() set a title (probably just set RequestContext::getMain() as the context).
As for the redundant queries, the fix is to figure out WhereTF they're really coming from rather than complaining about Lua using MediaWiki's i18n framework when reporting errors. Anomie (talk) 15:33, 3 April 2015 (UTC)