MediaWiki  1.34.0
ErrorPageError.php
Go to the documentation of this file.
1 <?php
28  const SEND_OUTPUT = 0;
29  const STAGE_OUTPUT = 1;
30  public $title, $msg, $params;
31 
39  public function __construct( $title, $msg, $params = [] ) {
40  $this->title = $title;
41  $this->msg = $msg;
42  $this->params = $params;
43 
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() );
51  }
52 
58  public function getMessageObject() {
59  if ( $this->msg instanceof Message ) {
60  return clone $this->msg;
61  }
62  return wfMessage( $this->msg, $this->params );
63  }
64 
65  public function report( $action = self::SEND_OUTPUT ) {
66  if ( self::isCommandLine() || defined( 'MW_API' ) ) {
67  parent::report();
68  } else {
69  global $wgOut;
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 ) {
76  $wgOut->output();
77  }
78  }
79  }
80 }
wfMessage
wfMessage( $key,... $params)
This is the function for getting translated interface messages.
Definition: GlobalFunctions.php:1264
ErrorPageError\$title
$title
Definition: ErrorPageError.php:30
ErrorPageError\getMessageObject
getMessageObject()
Return a Message object for this exception.
Definition: ErrorPageError.php:58
Message
ErrorPageError\report
report( $action=self::SEND_OUTPUT)
Definition: ErrorPageError.php:65
ErrorPageError\__construct
__construct( $title, $msg, $params=[])
Note: these arguments are keys into wfMessage(), not text!
Definition: ErrorPageError.php:39
ErrorPageError\STAGE_OUTPUT
const STAGE_OUTPUT
Definition: ErrorPageError.php:29
MWException
MediaWiki exception.
Definition: MWException.php:26
ILocalizedException
Interface for MediaWiki-localized exceptions.
Definition: ILocalizedException.php:27
ErrorPageError\SEND_OUTPUT
const SEND_OUTPUT
Definition: ErrorPageError.php:28
MWException\msg
msg( $key, $fallback,... $params)
Get a message from i18n.
Definition: MWException.php:75
ErrorPageError\$params
$params
Definition: ErrorPageError.php:30
$wgOut
$wgOut
Definition: Setup.php:886
ErrorPageError
An error page which can definitely be safely rendered using the OutputPage.
Definition: ErrorPageError.php:27
ErrorPageError\$msg
$msg
Definition: ErrorPageError.php:30