Localisation updates from https://translatewiki.net.
[mediawiki.git] / includes / exception / ErrorPageError.php
blob9b5a26821fa7d79cdcdf7e3ca5e130ca48197e47
1 <?php
2 /**
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
6 * (at your option) any later version.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License along
14 * with this program; if not, write to the Free Software Foundation, Inc.,
15 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 * http://www.gnu.org/copyleft/gpl.html
18 * @file
21 /**
22 * An error page which can definitely be safely rendered using the OutputPage.
24 * @since 1.7
25 * @ingroup Exception
27 class ErrorPageError extends MWException implements ILocalizedException {
28 public $title, $msg, $params;
30 /**
31 * Note: these arguments are keys into wfMessage(), not text!
33 * @param string|Message $title Message key (string) for page title, or a Message object
34 * @param string|Message $msg Message key (string) for error text, or a Message object
35 * @param array $params Array with parameters to wfMessage()
37 public function __construct( $title, $msg, $params = [] ) {
38 $this->title = $title;
39 $this->msg = $msg;
40 $this->params = $params;
42 // Bug 44111: Messages in the log files should be in English and not
43 // customized by the local wiki. So get the default English version for
44 // passing to the parent constructor. Our overridden report() below
45 // makes sure that the page shown to the user is not forced to English.
46 $enMsg = $this->getMessageObject();
47 $enMsg->inLanguage( 'en' )->useDatabase( false );
48 parent::__construct( $enMsg->text() );
51 /**
52 * Return a Message object for this exception
53 * @since 1.29
54 * @return Message
56 public function getMessageObject() {
57 if ( $this->msg instanceof Message ) {
58 return clone $this->msg;
60 return wfMessage( $this->msg, $this->params );
63 public function report() {
64 global $wgOut;
66 $wgOut->showErrorPage( $this->title, $this->msg, $this->params );
67 $wgOut->output();