Screenshot – note the title bar
"Internal error" page doesn't expand {{SITENAME}}.
Version: 1.23.0
Severity: minor
Attached:
Screenshot – note the title bar
"Internal error" page doesn't expand {{SITENAME}}.
Version: 1.23.0
Severity: minor
Attached:
(In reply to comment #1)
The most likely cause is 2bcffe8b, but why does it not work, I have no idea.
MWException::getPageTitle() was already broken. However, it was not
previously used for DBConnectionErrors.
The problem is that the message is not run through the preprocessor
(e.g. using MessageCache::transform()) before it is inserted into the
HTML.
It might be possible to change Exception::msg() to return a Message object,
now that we have RawMessage, which would make fixing this bug even more
trivial.
Please provide steps to reproduce this as I did verify (and have again, just now) that it works (both general exception, and from db connection errors).
By changing LocalSettings to trigger a connection error, from:
$wgDBtype = 'mysql';
$wgDBserver = 'localhost';
$wgDBpassword = '***';
to:
$wgDBtype = 'mysql';
$wgDBserver = 'localhost';
$wgDBpassword = '***blabla';
By default the message framework should be working fine (just db error), the message blob is used and the following is rendered:
<title>Internal error - alpha.Wiki</title>
When mimicking a broader error (i18n issue and $wgSitename issue), by:
... then the inline fallback is used and DefaultSettings apply, and the following is rendered:
<title>Test error - MediaWiki</title>
OK, looks like that wasn't a good way to reproduce it because it always uses the fallback in case of a db connection failure, since db connection failure prevents localisation from initialising.
I can reproduce the error when adding:
throw new MWException( 'X');
to a function bound to a parser hook (e.g. 'DoEditSectionLink'), then the following is rendered:
<h1 id="firstHeading">Internal error - {{SITENAME}}</h1>
Makes sense as, indeed, we call wfMessage()->plain().
(In reply to comment #4)
Makes sense as, indeed, we call wfMessage()->plain().
So as a quick fix, changing ->plain() to ->text() might work, assuming
that nothing really needs ->plain().
Change 116080 had a related patch set uploaded by PleaseStand:
Exceptions were directly outputting {{SITENAME}}.
(In reply to Kevin Israel (PleaseStand) from comment #2)
(In reply to comment #1)
The most likely cause is 2bcffe8b, but why does it not work, I have no idea.
MWException::getPageTitle() was already broken. However, it was not
previously used for DBConnectionErrors.
It seems that I confused myself. The change looks like it did in fact cause the bug by "[restoring the] sitename as part of error page document title" (for the reason explained in comment 2 and comment 4).
The site name was not already there, and it turns out that MWException::getPageTitle() is not in fact the right place to add it.
The result of #5 is that when the OutputPage code path is used, the h1 element contains the text "Internal error - {{SITENAME}}" and the title element contains "Internal error - {{SITENAME}} - Wikipedia" (if $wgSitename = "Wikipedia").
It is only the "else" case (OutputPage not used) that is missing the site name, and that is where text() would come in, though it might make sense to keep msg() how it is for now to avoid breaking things (and just replace {{SITENAME}}).
Change 116080 merged by jenkins-bot:
MWException: Expand {{SITENAME}} in pagetitle with Message::text()
Moving milestone to 1.24. If someone wants to fix it for 1.23, that'd be great, but we can't block release for this.
Change 135443 had a related patch set uploaded by PleaseStand:
DBConnectionError: Expand {{SITENAME}} in pagetitle with Message::text()
Change 135443 merged by jenkins-bot:
DBConnectionError: Expand {{SITENAME}} in pagetitle with Message::text()