MediaWiki  master
ErrorPageError.php
Go to the documentation of this file.
1 <?php
31  public const SEND_OUTPUT = 0;
32  public const STAGE_OUTPUT = 1;
33  public $title, $msg, $params;
34 
44  public function __construct( $title, $msg, $params = [] ) {
45  $this->title = $title;
46  $this->msg = $msg;
47  $this->params = $params;
48 
49  // T46111: Messages in the log files should be in English and not
50  // customized by the local wiki. So get the default English version for
51  // passing to the parent constructor. Our overridden report() below
52  // makes sure that the page shown to the user is not forced to English.
53  $enMsg = $this->getMessageObject();
54  $enMsg->inLanguage( 'en' )->useDatabase( false );
55  parent::__construct( $enMsg->text() );
56  }
57 
63  public function getMessageObject() {
64  if ( $this->msg instanceof Message ) {
65  return clone $this->msg;
66  }
67  return wfMessage( $this->msg, $this->params );
68  }
69 
77  public function report( $action = self::SEND_OUTPUT ) {
78  if ( self::isCommandLine() || defined( 'MW_API' ) ) {
79  parent::report();
80  } else {
81  global $wgOut;
82  $wgOut->showErrorPage( $this->title, $this->msg, $this->params );
83  // Allow skipping of the final output step, so that web-based page views
84  // from MediaWiki.php, can inspect the staged OutputPage state, and perform
85  // graceful shutdown via doPreOutputCommit first, just like for regular
86  // output when there isn't an error page.
87  if ( $action === self::SEND_OUTPUT ) {
88  $wgOut->output();
89  }
90  }
91  }
92 }
wfMessage
wfMessage( $key,... $params)
This is the function for getting translated interface messages.
Definition: GlobalFunctions.php:1219
ErrorPageError\$title
$title
Definition: ErrorPageError.php:33
ErrorPageError\getMessageObject
getMessageObject()
Return a Message object for this exception.
Definition: ErrorPageError.php:63
ErrorPageError\report
report( $action=self::SEND_OUTPUT)
Stable to override.
Definition: ErrorPageError.php:77
ErrorPageError\__construct
__construct( $title, $msg, $params=[])
Note: these arguments are keys into wfMessage(), not text!
Definition: ErrorPageError.php:44
ErrorPageError\STAGE_OUTPUT
const STAGE_OUTPUT
Definition: ErrorPageError.php:32
MWException
MediaWiki exception.
Definition: MWException.php:29
ILocalizedException
Interface for MediaWiki-localized exceptions.
Definition: ILocalizedException.php:29
ErrorPageError\SEND_OUTPUT
const SEND_OUTPUT
Definition: ErrorPageError.php:31
MWException\msg
msg( $key, $fallback,... $params)
Get a message from i18n.
Definition: MWException.php:81
ErrorPageError\$params
$params
Definition: ErrorPageError.php:33
Message
The Message class deals with fetching and processing of interface message into a variety of formats.
Definition: Message.php:161
$wgOut
$wgOut
Definition: Setup.php:781
ErrorPageError
An error page which can definitely be safely rendered using the OutputPage.
Definition: ErrorPageError.php:30
ErrorPageError\$msg
$msg
Definition: ErrorPageError.php:33