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( $key,... $params)
This is the function for getting translated interface messages.
if(!defined( 'MW_NO_SESSION') &&! $wgCommandLineMode) $wgOut
Definition: Setup.php:528
An error page which can definitely be safely rendered using the OutputPage.
report( $action=self::SEND_OUTPUT)
getMessageObject()
Return a Message object for this exception.
__construct( $title, $msg, $params=[])
Note: these arguments are keys into wfMessage(), not text!
MediaWiki exception.
Definition: MWException.php:32
msg( $key, $fallback,... $params)
Get a message from i18n.
Definition: MWException.php:85
The Message class deals with fetching and processing of interface message into a variety of formats.
Definition: Message.php:144
Interface for MediaWiki-localized exceptions.