MediaWiki master
ErrorPageError.php
Go to the documentation of this file.
1<?php
22
33 public const SEND_OUTPUT = 0;
34 public const STAGE_OUTPUT = 1;
35
37 public $title;
39 public $msg;
40 public array $params;
41
51 public function __construct( $title, $msg, $params = [] ) {
52 $this->title = $title;
53 $this->msg = $msg;
54 $this->params = $params;
55
56 // T46111: Messages in the log files should be in English and not
57 // customized by the local wiki. So get the default English version for
58 // passing to the parent constructor. Our overridden report() below
59 // makes sure that the page shown to the user is not forced to English.
60 $enMsg = $this->getMessageObject();
61 $enMsg->inLanguage( 'en' )->useDatabase( false );
62 parent::__construct( $enMsg->text() );
63 }
64
70 public function getMessageObject() {
71 if ( $this->msg instanceof Message ) {
72 return clone $this->msg;
73 }
74 return wfMessage( $this->msg, $this->params );
75 }
76
84 public function report( $action = self::SEND_OUTPUT ) {
85 if ( self::isCommandLine() || defined( 'MW_API' ) ) {
86 MWExceptionRenderer::output( $this, MWExceptionRenderer::AS_PRETTY );
87 } else {
88 global $wgOut;
89 $wgOut->showErrorPage( $this->title, $this->msg, $this->params );
90 // Allow skipping of the final output step, so that web-based page views
91 // from MediaWiki.php, can inspect the staged OutputPage state, and perform
92 // graceful shutdown via prepareForOutput() first, just like for regular
93 // output when there isn't an error page.
94 if ( $action === self::SEND_OUTPUT ) {
95 $wgOut->output();
96 }
97 }
98 }
99}
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:538
array $params
The job parameters.
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.
string MessageSpecifier $msg
string MessageSpecifier $title
__construct( $title, $msg, $params=[])
Note: these arguments are keys into wfMessage(), not text!
MediaWiki exception.
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:158
Interface for MediaWiki-localized exceptions.