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
22 * An error page which can definitely be safely rendered using the OutputPage.
27 class ErrorPageError
extends MWException
implements ILocalizedException
{
28 const SEND_OUTPUT
= 0;
29 const STAGE_OUTPUT
= 1;
30 public $title, $msg, $params;
33 * Note: these arguments are keys into wfMessage(), not text!
35 * @param string|Message $title Message key (string) for page title, or a Message object
36 * @param string|Message $msg Message key (string) for error text, or a Message object
37 * @param array $params Array with parameters to wfMessage()
39 public function __construct( $title, $msg, $params = [] ) {
40 $this->title
= $title;
42 $this->params
= $params;
44 // T46111: Messages in the log files should be in English and not
45 // customized by the local wiki. So get the default English version for
46 // passing to the parent constructor. Our overridden report() below
47 // makes sure that the page shown to the user is not forced to English.
48 $enMsg = $this->getMessageObject();
49 $enMsg->inLanguage( 'en' )->useDatabase( false );
50 parent
::__construct( $enMsg->text() );
54 * Return a Message object for this exception
58 public function getMessageObject() {
59 if ( $this->msg
instanceof Message
) {
60 return clone $this->msg
;
62 return wfMessage( $this->msg
, $this->params
);
65 public function report( $action = self
::SEND_OUTPUT
) {
66 if ( self
::isCommandLine() ||
defined( 'MW_API' ) ) {
70 $wgOut->showErrorPage( $this->title
, $this->msg
, $this->params
);
71 // Allow skipping of the final output step, so that web-based page views
72 // from MediaWiki.php, can inspect the staged OutputPage state, and perform
73 // graceful shutdown via doPreOutputCommit first, just like for regular
74 // output when there isn't an error page.
75 if ( $action === self
::SEND_OUTPUT
) {