Previously an ugly {{SITENAME}} would show up for exceptions
that happened in the middle of processing a message
Change-Id: I4e3b675673dc3b74f89e4325f6a0a8b44162f478
* @return string Message with arguments replaced
*/
public function msg( $key, $fallback /*[, params...] */ ) {
* @return string Message with arguments replaced
*/
public function msg( $key, $fallback /*[, params...] */ ) {
$args = array_slice( func_get_args(), 2 );
$args = array_slice( func_get_args(), 2 );
if ( $this->useMessageCache() ) {
try {
if ( $this->useMessageCache() ) {
try {
- return wfMessage( $key, $args )->text();
+ $res = wfMessage( $key, $args )->text();
} catch ( Exception $e ) {
}
}
} catch ( Exception $e ) {
}
}
- return wfMsgReplaceArgs( $fallback, $args );
+ if ( $res === false ) {
+ $res = wfMsgReplaceArgs( $fallback, $args );
+ // If an exception happens inside message rendering,
+ // {{SITENAME}} sometimes won't be replaced.
+ $res = preg_replace( '/\{\{SITENAME\}\}/', $wgSitename, $res );
+ }
+ return $res;
global $wgOut, $wgSitename;
if ( $this->useOutputPage() ) {
$wgOut->prepareErrorPage( $this->getPageTitle() );
global $wgOut, $wgSitename;
if ( $this->useOutputPage() ) {
$wgOut->prepareErrorPage( $this->getPageTitle() );
+ // Manually set the html title, since sometimes
+ // {{SITENAME}} does not get replaced for exceptions
+ // happening inside message rendering.
+ $wgOut->setHTMLTitle(
+ $this->msg(
+ 'pagetitle',
+ "$1 - $wgSitename",
+ $this->getPageTitle()
+ )
+ );
$wgOut->addHTML( $this->getHTML() );
$wgOut->addHTML( $this->getHTML() );
* @return string Message with arguments replaced
*/
private static function msg( $key, $fallback /*[, params...] */ ) {
* @return string Message with arguments replaced
*/
private static function msg( $key, $fallback /*[, params...] */ ) {
$args = array_slice( func_get_args(), 2 );
try {
$args = array_slice( func_get_args(), 2 );
try {
- return wfMessage( $key, $args )->text();
+ $res = wfMessage( $key, $args )->text();
} catch ( Exception $e ) {
} catch ( Exception $e ) {
- return wfMsgReplaceArgs( $fallback, $args );
+ $res = wfMsgReplaceArgs( $fallback, $args );
+ // If an exception happens inside message rendering,
+ // {{SITENAME}} sometimes won't be replaced.
+ $res = preg_replace( '/\{\{SITENAME\}\}/', $wgSitename, $res );