MediaWiki master
BadTitleError.php
Go to the documentation of this file.
1<?php
7namespace MediaWiki\Exception;
8
11
33 public function __construct( $msg = 'badtitletext', $params = [] ) {
34 if ( $msg instanceof MalformedTitleException ) {
35 $errorMessage = $msg->getErrorMessage();
36 if ( !$errorMessage ) {
37 parent::__construct( 'badtitle', 'badtitletext', [] );
38 } else {
39 $errorMessageParams = $msg->getErrorMessageParameters();
40 parent::__construct( 'badtitle', $errorMessage, $errorMessageParams );
41 }
42 } else {
43 parent::__construct( 'badtitle', $msg, $params );
44 }
45 }
46
50 public function report( $action = self::SEND_OUTPUT ) {
51 global $wgOut;
52
53 $wgOut->setStatusCode( 404 );
54
55 parent::report( self::STAGE_OUTPUT );
56
57 // Unconditionally cache the error for an hour, see T316932
58 $wgOut->enableClientCache();
59 $wgOut->setCdnMaxage( 3600 );
60
61 if ( $action === self::SEND_OUTPUT ) {
62 $wgOut->output();
63 }
64 }
65}
66
68class_alias( BadTitleError::class, 'BadTitleError' );
if(MW_ENTRY_POINT==='index') if(!defined( 'MW_NO_SESSION') &&MW_ENTRY_POINT !=='cli' $wgOut
Definition Setup.php:551
Show an error page on a badtitle.
__construct( $msg='badtitletext', $params=[])
report( $action=self::SEND_OUTPUT)
to override
An error page which can definitely be safely rendered using the OutputPage.
The Message class deals with fetching and processing of interface message into a variety of formats.
Definition Message.php:144
MalformedTitleException is thrown when a TitleParser is unable to parse a title string.