MediaWiki  master
BadTitleError.php
Go to the documentation of this file.
1 <?php
42  public function __construct( $msg = 'badtitletext', $params = [] ) {
43  if ( $msg instanceof MalformedTitleException ) {
44  $errorMessage = $msg->getErrorMessage();
45  if ( !$errorMessage ) {
46  parent::__construct( 'badtitle', 'badtitletext', [] );
47  } else {
48  $errorMessageParams = $msg->getErrorMessageParameters();
49  parent::__construct( 'badtitle', $errorMessage, $errorMessageParams );
50  }
51  } else {
52  parent::__construct( 'badtitle', $msg, $params );
53  }
54  }
55 
59  public function report( $action = self::SEND_OUTPUT ) {
60  global $wgOut;
61 
62  $wgOut->setStatusCode( 404 );
63 
64  parent::report( self::STAGE_OUTPUT );
65 
66  // Unconditionally cache the error for an hour, see T316932
67  $wgOut->enableClientCache();
68  $wgOut->setCdnMaxage( 3600 );
69 
70  if ( $action === self::SEND_OUTPUT ) {
71  $wgOut->output();
72  }
73  }
74 }
if(!defined( 'MW_NO_SESSION') &&! $wgCommandLineMode) $wgOut
Definition: Setup.php:527
Show an error page on a badtitle.
__construct( $msg='badtitletext', $params=[])
report( $action=self::SEND_OUTPUT)
Stability: stableto override
An error page which can definitely be safely rendered using the OutputPage.
MalformedTitleException is thrown when a TitleParser is unable to parse a title string.