MediaWiki REL1_34
ErrorPageError.php
Go to the documentation of this file.
1<?php
28 const SEND_OUTPUT = 0;
29 const STAGE_OUTPUT = 1;
31
39 public function __construct( $title, $msg, $params = [] ) {
40 $this->title = $title;
41 $this->msg = $msg;
42 $this->params = $params;
43
44 // T46111: Messages in the log files should be in English and not
45 // customized by the local wiki. So get the default English version for
46 // passing to the parent constructor. Our overridden report() below
47 // makes sure that the page shown to the user is not forced to English.
48 $enMsg = $this->getMessageObject();
49 $enMsg->inLanguage( 'en' )->useDatabase( false );
50 parent::__construct( $enMsg->text() );
51 }
52
58 public function getMessageObject() {
59 if ( $this->msg instanceof Message ) {
60 return clone $this->msg;
61 }
62 return wfMessage( $this->msg, $this->params );
63 }
64
65 public function report( $action = self::SEND_OUTPUT ) {
66 if ( self::isCommandLine() || defined( 'MW_API' ) ) {
67 parent::report();
68 } else {
69 global $wgOut;
70 $wgOut->showErrorPage( $this->title, $this->msg, $this->params );
71 // Allow skipping of the final output step, so that web-based page views
72 // from MediaWiki.php, can inspect the staged OutputPage state, and perform
73 // graceful shutdown via doPreOutputCommit first, just like for regular
74 // output when there isn't an error page.
75 if ( $action === self::SEND_OUTPUT ) {
76 $wgOut->output();
77 }
78 }
79 }
80}
wfMessage( $key,... $params)
This is the function for getting translated interface messages.
$wgOut
Definition Setup.php:885
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.
__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 provides methods which fulfil two basic services:
Definition Message.php:162
Interface for MediaWiki-localized exceptions.