More visual and xhtml fixes for file cache failback
This commit is contained in:
parent
49e97b4c41
commit
fcd22b9a84
3 changed files with 31 additions and 10 deletions
|
|
@ -161,7 +161,7 @@ class MWException extends Exception {
|
|||
if( $hookResult = $this->runHooks( get_class( $this ) . "Raw" ) ) {
|
||||
die( $hookResult );
|
||||
}
|
||||
if ( defined( 'MEDIAWIKI_INSTALL' ) ) {
|
||||
if ( defined( 'MEDIAWIKI_INSTALL' ) || $this->htmlBodyOnly() ) {
|
||||
echo $this->getHTML();
|
||||
} else {
|
||||
echo $this->htmlHeader();
|
||||
|
|
@ -217,6 +217,13 @@ class MWException extends Exception {
|
|||
function htmlFooter() {
|
||||
echo "</body></html>";
|
||||
}
|
||||
|
||||
/**
|
||||
* headers handled by subclass?
|
||||
*/
|
||||
function htmlBodyOnly() {
|
||||
return false;
|
||||
}
|
||||
|
||||
static function isCommandLine() {
|
||||
return !empty( $GLOBALS['wgCommandLineMode'] ) && !defined( 'MEDIAWIKI_INSTALL' );
|
||||
|
|
|
|||
|
|
@ -2586,12 +2586,25 @@ class DBConnectionError extends DBError {
|
|||
|
||||
$extra = $this->searchForm();
|
||||
|
||||
if($wgUseFileCache) {
|
||||
if( $wgUseFileCache ) {
|
||||
$cache = $this->fileCachedPage();
|
||||
if ( $cache !== null ) $extra = $cache;
|
||||
# Cached version on file system?
|
||||
if( $cache !== null ) {
|
||||
# Hack: extend the body for error messages
|
||||
$cache = str_replace( array('</html>','</body>'), '', $cache );
|
||||
# Add cache notice...
|
||||
$cachederror = "This is a cached copy of the requested page, and may not be up to date. ";
|
||||
# Localize it if possible...
|
||||
if( $wgLang instanceof Language ) {
|
||||
$cachederror = htmlspecialchars( $wgLang->getMessage( 'dberr-cachederror' ) );
|
||||
}
|
||||
$warning = "<div style='color:red;font-size:150%;font-weight:bold;'>$cachederror</div>";
|
||||
# Output cached page with notices on bottom and re-close body
|
||||
return "{$cache}{$warning}<hr />$text<hr />$extra</body></html>";
|
||||
}
|
||||
}
|
||||
|
||||
return $text . '<hr />' . $extra;
|
||||
# Headers needed here - output is just the error message
|
||||
return $this->htmlHeader()."$text<hr />$extra".$this->htmlFooter();
|
||||
}
|
||||
|
||||
function searchForm() {
|
||||
|
|
@ -2635,10 +2648,8 @@ EOT;
|
|||
function fileCachedPage() {
|
||||
global $wgTitle, $title, $wgLang, $wgOut;
|
||||
if( $wgOut->isDisabled() ) return; // Done already?
|
||||
$cachederror = "The following is a cached copy of the requested page, and may not be up to date. ";
|
||||
$mainpage = 'Main Page';
|
||||
if ( $wgLang instanceof Language ) {
|
||||
$cachederror = htmlspecialchars( $wgLang->getMessage( 'dberr-cachederror' ) );
|
||||
$mainpage = htmlspecialchars( $wgLang->getMessage( 'mainpage' ) );
|
||||
}
|
||||
|
||||
|
|
@ -2652,12 +2663,15 @@ EOT;
|
|||
|
||||
$cache = new HTMLFileCache( $t );
|
||||
if( $cache->isFileCached() ) {
|
||||
$warning = "<div style='color:red;font-size:150%;font-weight:bold;'>$cachederror</div>";
|
||||
return $warning . $cache->fetchPageText();
|
||||
return $cache->fetchPageText();
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
function htmlBodyOnly() {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -3871,6 +3871,6 @@ Enter the filename without the "{{ns:file}}:" prefix.',
|
|||
'dberr-info' => '(Cannot contact the database server: $1)',
|
||||
'dberr-usegoogle' => 'You can try searching via Google in the meantime.',
|
||||
'dberr-outofdate' => 'Note that their indexes of our content may be out of date.',
|
||||
'dberr-cachederror' => 'The following is a cached copy of the requested page, and may not be up to date.',
|
||||
'dberr-cachederror' => 'This is a cached copy of the requested page, and may not be up to date.',
|
||||
|
||||
);
|
||||
|
|
|
|||
Loading…
Reference in a new issue