r48400 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r48399‎ | r48400 | r48401 >
Date:03:16, 14 March 2009
Author:aaron
Status:ok
Tags:
Comment:
More visual and xhtml fixes for file cache failback
Modified paths:
  • /trunk/phase3/includes/Exception.php (modified) (history)
  • /trunk/phase3/includes/db/Database.php (modified) (history)
  • /trunk/phase3/languages/messages/MessagesEn.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/db/Database.php
@@ -2586,12 +2586,25 @@
25872587
25882588 $extra = $this->searchForm();
25892589
2590 - if($wgUseFileCache) {
 2590+ if( $wgUseFileCache ) {
25912591 $cache = $this->fileCachedPage();
2592 - if ( $cache !== null ) $extra = $cache;
 2592+ # Cached version on file system?
 2593+ if( $cache !== null ) {
 2594+ # Hack: extend the body for error messages
 2595+ $cache = str_replace( array('</html>','</body>'), '', $cache );
 2596+ # Add cache notice...
 2597+ $cachederror = "This is a cached copy of the requested page, and may not be up to date. ";
 2598+ # Localize it if possible...
 2599+ if( $wgLang instanceof Language ) {
 2600+ $cachederror = htmlspecialchars( $wgLang->getMessage( 'dberr-cachederror' ) );
 2601+ }
 2602+ $warning = "<div style='color:red;font-size:150%;font-weight:bold;'>$cachederror</div>";
 2603+ # Output cached page with notices on bottom and re-close body
 2604+ return "{$cache}{$warning}<hr />$text<hr />$extra</body></html>";
 2605+ }
25932606 }
2594 -
2595 - return $text . '<hr />' . $extra;
 2607+ # Headers needed here - output is just the error message
 2608+ return $this->htmlHeader()."$text<hr />$extra".$this->htmlFooter();
25962609 }
25972610
25982611 function searchForm() {
@@ -2635,10 +2648,8 @@
26362649 function fileCachedPage() {
26372650 global $wgTitle, $title, $wgLang, $wgOut;
26382651 if( $wgOut->isDisabled() ) return; // Done already?
2639 - $cachederror = "The following is a cached copy of the requested page, and may not be up to date. ";
26402652 $mainpage = 'Main Page';
26412653 if ( $wgLang instanceof Language ) {
2642 - $cachederror = htmlspecialchars( $wgLang->getMessage( 'dberr-cachederror' ) );
26432654 $mainpage = htmlspecialchars( $wgLang->getMessage( 'mainpage' ) );
26442655 }
26452656
@@ -2652,12 +2663,15 @@
26532664
26542665 $cache = new HTMLFileCache( $t );
26552666 if( $cache->isFileCached() ) {
2656 - $warning = "<div style='color:red;font-size:150%;font-weight:bold;'>$cachederror</div>";
2657 - return $warning . $cache->fetchPageText();
 2667+ return $cache->fetchPageText();
26582668 } else {
26592669 return '';
26602670 }
26612671 }
 2672+
 2673+ function htmlBodyOnly() {
 2674+ return true;
 2675+ }
26622676
26632677 }
26642678
Index: trunk/phase3/includes/Exception.php
@@ -161,7 +161,7 @@
162162 if( $hookResult = $this->runHooks( get_class( $this ) . "Raw" ) ) {
163163 die( $hookResult );
164164 }
165 - if ( defined( 'MEDIAWIKI_INSTALL' ) ) {
 165+ if ( defined( 'MEDIAWIKI_INSTALL' ) || $this->htmlBodyOnly() ) {
166166 echo $this->getHTML();
167167 } else {
168168 echo $this->htmlHeader();
@@ -217,6 +217,13 @@
218218 function htmlFooter() {
219219 echo "</body></html>";
220220 }
 221+
 222+ /**
 223+ * headers handled by subclass?
 224+ */
 225+ function htmlBodyOnly() {
 226+ return false;
 227+ }
221228
222229 static function isCommandLine() {
223230 return !empty( $GLOBALS['wgCommandLineMode'] ) && !defined( 'MEDIAWIKI_INSTALL' );
Index: trunk/phase3/languages/messages/MessagesEn.php
@@ -3871,6 +3871,6 @@
38723872 'dberr-info' => '(Cannot contact the database server: $1)',
38733873 'dberr-usegoogle' => 'You can try searching via Google in the meantime.',
38743874 'dberr-outofdate' => 'Note that their indexes of our content may be out of date.',
3875 -'dberr-cachederror' => 'The following is a cached copy of the requested page, and may not be up to date.',
 3875+'dberr-cachederror' => 'This is a cached copy of the requested page, and may not be up to date.',
38763876
38773877 );

Status & tagging log