MediaWiki master
ErrorPageError.php
Go to the documentation of this file.
1<?php
21namespace MediaWiki\Exception;
22
25
36 public const SEND_OUTPUT = 0;
37 public const STAGE_OUTPUT = 1;
38
40 public $title;
42 public $msg;
43 public array $params;
44
54 public function __construct( $title, $msg, $params = [] ) {
55 $this->title = $title;
56 $this->msg = $msg;
57 $this->params = $params;
58
59 // T46111: Messages in the log files should be in English and not
60 // customized by the local wiki. So get the default English version for
61 // passing to the parent constructor. Our overridden report() below
62 // makes sure that the page shown to the user is not forced to English.
63 $enMsg = $this->getMessageObject();
64 $enMsg->inLanguage( 'en' )->useDatabase( false );
65 parent::__construct( $enMsg->text() );
66 }
67
73 public function getMessageObject() {
74 if ( $this->msg instanceof Message ) {
75 return clone $this->msg;
76 }
77 return wfMessage( $this->msg, $this->params );
78 }
79
87 public function report( $action = self::SEND_OUTPUT ) {
88 if ( self::isCommandLine() || defined( 'MW_API' ) ) {
90 } else {
91 global $wgOut;
92 $wgOut->showErrorPage( $this->title, $this->msg, $this->params );
93 // Allow skipping of the final output step, so that web-based page views
94 // from MediaWiki.php, can inspect the staged OutputPage state, and perform
95 // graceful shutdown via prepareForOutput() first, just like for regular
96 // output when there isn't an error page.
97 if ( $action === self::SEND_OUTPUT ) {
98 $wgOut->output();
99 }
100 }
101 }
102}
103
105class_alias( ErrorPageError::class, 'ErrorPageError' );
wfMessage( $key,... $params)
This is the function for getting translated interface messages.
if(!defined( 'MW_NO_SESSION') &&MW_ENTRY_POINT !=='cli' $wgOut
Definition Setup.php:562
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:155
Interface for MediaWiki-localized exceptions.