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