From 03d4947289bffbcee0fad0a5a1480f29bcfb8bf1 Mon Sep 17 00:00:00 2001 From: Timo Tijhof Date: Fri, 14 Mar 2014 06:02:45 +0100 Subject: [PATCH] MWException: Fix sitename appearing twice in The MWException::getPageTitle method is wrapping the page title in the 'pagetitle' ($1 - sitename) message, but OutputPage does this as well when outputing <title>. OutputPage::prepareErrorPage takes the first parameter as page title (unwrapped, appears in <h1>,) and the second optional one is for <title>, which (if omitted, like before) results in pagetitle being applied by OutputPage. Now that we specify them separately, this also removes the sitename from the <h1> on the page, which always looked weird. It also fixes DBQueryError (extends MWException) where previously no sitename was added, it just returns 'databaseerror' from its DBQueryError::getPageTitle() method. Change-Id: I85d65d89e72b4497a050f440524ff6f959518b88 --- includes/exception/MWException.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/includes/exception/MWException.php b/includes/exception/MWException.php index 797d406fe8..136fb89960 100644 --- a/includes/exception/MWException.php +++ b/includes/exception/MWException.php @@ -173,8 +173,7 @@ class MWException extends Exception { * @return string */ public function getPageTitle() { - global $wgSitename; - return $this->msg( 'pagetitle', "$1 - $wgSitename", $this->msg( 'internalerror', 'Internal error' ) ); + return $this->msg( 'internalerror', 'Internal error' ); } /** @@ -206,7 +205,7 @@ class MWException extends Exception { * Output the exception report using HTML. */ public function reportHTML() { - global $wgOut; + global $wgOut, $wgSitename; if ( $this->useOutputPage() ) { $wgOut->prepareErrorPage( $this->getPageTitle() ); @@ -222,7 +221,8 @@ class MWException extends Exception { header( 'Content-Type: text/html; charset=utf-8' ); echo "<!DOCTYPE html>\n" . '<html><head>' . - '<title>' . htmlspecialchars( $this->getPageTitle() ) . '' . + // Mimick OutputPage::setPageTitle behaviour + '' . htmlspecialchars( $this->msg( 'pagetitle', "$1 - $wgSitename", $this->getPageTitle() ) ) . '' . '' . "\n"; -- 2.20.1