* Clean up the ugly adding-then-removing-then-readding HTML <head> and <body> tags in DBConnectionError, deprecates MWException::htmlBodyOnly()
* Also deprecates MWException::htmlHeader(), removes code duplication since MWException::reportHTML() can safely call wfDie() and get an output format appropriate for the entry point
* Copy a couple of HTML headers (Cache-control, Pragma and Content-type) to the wfDie() implementation.
die( $hookResult );
}
- if ( defined( 'MEDIAWIKI_INSTALL' ) || $this->htmlBodyOnly() ) {
- echo $this->getHTML();
+ $html = $this->getHTML();
+ if ( defined( 'MEDIAWIKI_INSTALL' ) ) {
+ echo $html;
} else {
- echo $this->htmlHeader();
- echo $this->getHTML();
- echo $this->htmlFooter();
+ wfDie( $html );
}
}
}
/**
* Send headers and output the beginning of the html page if not using
* $wgOut to output the exception.
+ * @deprecated since 1.18 call wfDie() if you need to die immediately
*/
function htmlHeader() {
global $wgLogo, $wgLang;
/**
* print the end of the html page if not using $wgOut.
+ * @deprecated since 1.18
*/
function htmlFooter() {
return Html::closeElement( 'body' ) . Html::closeElement( 'html' );
}
- /**
- * headers handled by subclass?
- */
- function htmlBodyOnly() {
- return false;
- }
-
static function isCommandLine() {
return !empty( $GLOBALS['wgCommandLineMode'] ) && !defined( 'MEDIAWIKI_INSTALL' );
}
$extra = $this->searchForm();
+ return "$text<hr />$extra";
+ }
+
+ public function reportHTML(){
+ global $wgUseFileCache;
+
+ # Check whether we can serve a file-cached copy of the page with the error underneath
if ( $wgUseFileCache ) {
try {
$cache = $this->fileCachedPage();
'</div>';
# Output cached page with notices on bottom and re-close body
- return "{$cache}<hr />$text<hr />$extra</body></html>";
+ echo "{$cache}<hr />{$this->getHTML()}</body></html>";
+ return;
}
} catch ( MWException $e ) {
// Do nothing, just use the default page
}
}
- # Headers needed here - output is just the error message
- return $this->htmlHeader() . "$text<hr />$extra" . $this->htmlFooter();
+ # We can't, cough and die in the usual fashion
+ return parent::reportHTML();
}
function searchForm() {
return '';
}
}
-
- function htmlBodyOnly() {
- return true;
- }
}
/**
: 'http://upload.wikimedia.org/wikipedia/commons/1/1c/MediaWiki_logo.png';
header( $_SERVER['SERVER_PROTOCOL'] . ' 500 MediaWiki configuration Error', true, 500 );
+ header( 'Content-type: text/html; charset=UTF-8' );
+ // Don't cache error pages! They cause no end of trouble...
+ header( 'Cache-control: none' );
+ header( 'Pragma: nocache' );
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">