X-Git-Url: http://git.cyclocoop.org/?a=blobdiff_plain;f=includes%2Fexception%2FMWException.php;h=af835e4776e90f7eb9786a0d0c6b6677e977032f;hb=f44c1ff158f9f8bb4ec5b7e7a375c90f6817f384;hp=b3e9422b8d32238ddb9d3956c59c02e1ada735a8;hpb=d256246c2ae337b5232235edb547f3a396e1cbc9;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/exception/MWException.php b/includes/exception/MWException.php index b3e9422b8d..af835e4776 100644 --- a/includes/exception/MWException.php +++ b/includes/exception/MWException.php @@ -73,15 +73,26 @@ class MWException extends Exception { * @return string Message with arguments replaced */ public function msg( $key, $fallback /*[, params...] */ ) { + global $wgSitename; $args = array_slice( func_get_args(), 2 ); + // FIXME: Keep logic in sync with MWExceptionRenderer::msg. + $res = false; if ( $this->useMessageCache() ) { try { - return wfMessage( $key, $args )->text(); + $res = wfMessage( $key, $args )->text(); } 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 = strtr( $res, [ + '{{SITENAME}}' => $wgSitename, + ] ); + } + return $res; } /** @@ -154,6 +165,16 @@ class MWException extends Exception { 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() );