MediaWiki master
ErrorPageError.php
Go to the documentation of this file.
1<?php
7namespace MediaWiki\Exception;
8
11
22 public const SEND_OUTPUT = 0;
23 public const STAGE_OUTPUT = 1;
24
26 public $title;
28 public $msg;
29 public array $params;
30
40 public function __construct( $title, $msg, $params = [] ) {
41 $this->title = $title;
42 $this->msg = $msg;
43 $this->params = $params;
44
45 // T46111: Messages in the log files should be in English and not
46 // customized by the local wiki. So get the default English version for
47 // passing to the parent constructor. Our overridden report() below
48 // makes sure that the page shown to the user is not forced to English.
49 $enMsg = $this->getMessageObject();
50 $enMsg->inLanguage( 'en' )->useDatabase( false );
51 parent::__construct( $enMsg->text() );
52 }
53
59 public function getMessageObject() {
60 if ( $this->msg instanceof Message ) {
61 return clone $this->msg;
62 }
63 return wfMessage( $this->msg, $this->params );
64 }
65
73 public function report( $action = self::SEND_OUTPUT ) {
74 if ( self::isCommandLine() || defined( 'MW_API' ) ) {
76 } else {
77 global $wgOut;
78 $wgOut->showErrorPage( $this->title, $this->msg, $this->params );
79 // Allow skipping of the final output step, so that web-based page views
80 // from MediaWiki.php, can inspect the staged OutputPage state, and perform
81 // graceful shutdown via prepareForOutput() first, just like for regular
82 // output when there isn't an error page.
83 if ( $action === self::SEND_OUTPUT ) {
84 $wgOut->output();
85 }
86 }
87 }
88}
89
91class_alias( ErrorPageError::class, 'ErrorPageError' );
wfMessage( $key,... $params)
This is the function for getting translated interface messages.
if(MW_ENTRY_POINT==='index') if(!defined( 'MW_NO_SESSION') &&MW_ENTRY_POINT !=='cli' $wgOut
Definition Setup.php:551
An error page which can definitely be safely rendered using the OutputPage.
report( $action=self::SEND_OUTPUT)
__construct( $title, $msg, $params=[])
Note: these arguments are keys into wfMessage(), not text!
getMessageObject()
Return a Message object for this exception.
static output(Throwable $e, $mode, ?Throwable $eNew=null)
msg( $key, $fallback,... $params)
Get a message from i18n.
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.