MediaWiki  master
BadTitleError.php
Go to the documentation of this file.
1 <?php
22 
44  public function __construct( $msg = 'badtitletext', $params = [] ) {
45  if ( $msg instanceof MalformedTitleException ) {
46  $errorMessage = $msg->getErrorMessage();
47  if ( !$errorMessage ) {
48  parent::__construct( 'badtitle', 'badtitletext', [] );
49  } else {
50  $errorMessageParams = $msg->getErrorMessageParameters();
51  parent::__construct( 'badtitle', $errorMessage, $errorMessageParams );
52  }
53  } else {
54  parent::__construct( 'badtitle', $msg, $params );
55  }
56  }
57 
61  public function report( $action = self::SEND_OUTPUT ) {
62  global $wgOut;
63 
64  $wgOut->setStatusCode( 404 );
65 
66  parent::report( self::STAGE_OUTPUT );
67 
68  // Unconditionally cache the error for an hour, see T316932
69  $wgOut->enableClientCache();
70  $wgOut->setCdnMaxage( 3600 );
71 
72  if ( $action === self::SEND_OUTPUT ) {
73  $wgOut->output();
74  }
75  }
76 }
if(!defined( 'MW_NO_SESSION') &&! $wgCommandLineMode) $wgOut
Definition: Setup.php:535
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.