MediaWiki master
BadTitleError.php
Go to the documentation of this file.
1<?php
21namespace MediaWiki\Exception;
22
25
47 public function __construct( $msg = 'badtitletext', $params = [] ) {
48 if ( $msg instanceof MalformedTitleException ) {
49 $errorMessage = $msg->getErrorMessage();
50 if ( !$errorMessage ) {
51 parent::__construct( 'badtitle', 'badtitletext', [] );
52 } else {
53 $errorMessageParams = $msg->getErrorMessageParameters();
54 parent::__construct( 'badtitle', $errorMessage, $errorMessageParams );
55 }
56 } else {
57 parent::__construct( 'badtitle', $msg, $params );
58 }
59 }
60
64 public function report( $action = self::SEND_OUTPUT ) {
65 global $wgOut;
66
67 $wgOut->setStatusCode( 404 );
68
69 parent::report( self::STAGE_OUTPUT );
70
71 // Unconditionally cache the error for an hour, see T316932
72 $wgOut->enableClientCache();
73 $wgOut->setCdnMaxage( 3600 );
74
75 if ( $action === self::SEND_OUTPUT ) {
76 $wgOut->output();
77 }
78 }
79}
80
82class_alias( BadTitleError::class, 'BadTitleError' );
if(!defined( 'MW_NO_SESSION') &&MW_ENTRY_POINT !=='cli' $wgOut
Definition Setup.php:562
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:155
MalformedTitleException is thrown when a TitleParser is unable to parse a title string.