MediaWiki master
BadTitleError.php
Go to the documentation of this file.
1<?php
23
45 public function __construct( $msg = 'badtitletext', $params = [] ) {
46 if ( $msg instanceof MalformedTitleException ) {
47 $errorMessage = $msg->getErrorMessage();
48 if ( !$errorMessage ) {
49 parent::__construct( 'badtitle', 'badtitletext', [] );
50 } else {
51 $errorMessageParams = $msg->getErrorMessageParameters();
52 parent::__construct( 'badtitle', $errorMessage, $errorMessageParams );
53 }
54 } else {
55 parent::__construct( 'badtitle', $msg, $params );
56 }
57 }
58
62 public function report( $action = self::SEND_OUTPUT ) {
63 global $wgOut;
64
65 $wgOut->setStatusCode( 404 );
66
67 parent::report( self::STAGE_OUTPUT );
68
69 // Unconditionally cache the error for an hour, see T316932
70 $wgOut->enableClientCache();
71 $wgOut->setCdnMaxage( 3600 );
72
73 if ( $action === self::SEND_OUTPUT ) {
74 $wgOut->output();
75 }
76 }
77}
if(!defined( 'MW_NO_SESSION') &&MW_ENTRY_POINT !=='cli' $wgOut
Definition Setup.php:538
array $params
The job parameters.
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.
string MessageSpecifier $msg
The Message class deals with fetching and processing of interface message into a variety of formats.
Definition Message.php:158
MalformedTitleException is thrown when a TitleParser is unable to parse a title string.