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