diff options
author | Pierre Schmitz <pierre@archlinux.de> | 2012-05-03 13:01:35 +0200 |
---|---|---|
committer | Pierre Schmitz <pierre@archlinux.de> | 2012-05-03 13:01:35 +0200 |
commit | d9022f63880ce039446fba8364f68e656b7bf4cb (patch) | |
tree | 16b40fbf17bf7c9ee6f4ead25b16dd192378050a /includes/db/DatabaseError.php | |
parent | 27cf83d177256813e2e802241085fce5dd0f3fb9 (diff) |
Update to MediaWiki 1.19.0
Diffstat (limited to 'includes/db/DatabaseError.php')
-rw-r--r-- | includes/db/DatabaseError.php | 54 |
1 files changed, 39 insertions, 15 deletions
diff --git a/includes/db/DatabaseError.php b/includes/db/DatabaseError.php index b7fb1b22..836d7814 100644 --- a/includes/db/DatabaseError.php +++ b/includes/db/DatabaseError.php @@ -82,11 +82,19 @@ class DBConnectionError extends DBError { parent::__construct( $db, $msg ); } + /** + * @return bool + */ function useOutputPage() { // Not likely to work return false; } + /** + * @param $key + * @param $fallback + * @return string + */ function msg( $key, $fallback /*[, params...] */ ) { global $wgLang; @@ -100,6 +108,9 @@ class DBConnectionError extends DBError { return wfMsgReplaceArgs( $message, $args ); } + /** + * @return bool + */ function getLogMessage() { # Don't send to the exception log return false; @@ -171,7 +182,7 @@ class DBConnectionError extends DBError { } # We can't, cough and die in the usual fashion - return parent::reportHTML(); + parent::reportHTML(); } /** @@ -193,7 +204,7 @@ class DBConnectionError extends DBError { <div style="margin: 1.5em">$usegoogle<br /> <small>$outofdate</small></div> <!-- SiteSearch Google --> -<form method="get" action="http://www.google.com/search" id="googlesearch"> +<form method="get" action="//www.google.com/search" id="googlesearch"> <input type="hidden" name="domains" value="$server" /> <input type="hidden" name="num" value="50" /> <input type="hidden" name="ie" value="UTF-8" /> @@ -215,21 +226,28 @@ EOT; * @return string */ private function fileCachedPage() { - global $wgTitle, $wgOut; + global $wgTitle, $wgOut, $wgRequest; if ( $wgOut->isDisabled() ) { - return; // Done already? + return ''; // Done already? } - if ( $wgTitle ) { - $t =& $wgTitle; + if ( $wgTitle ) { // use $wgTitle if we managed to set it + $t = $wgTitle->getPrefixedDBkey(); } else { - $t = Title::newFromText( $this->msg( 'mainpage', 'Main Page' ) ); + # Fallback to the raw title URL param. We can't use the Title + # class is it may hit the interwiki table and give a DB error. + # We may get a cache miss due to not sanitizing the title though. + $t = str_replace( ' ', '_', $wgRequest->getVal( 'title' ) ); + if ( $t == '' ) { // fallback to main page + $t = Title::newFromText( + $this->msg( 'mainpage', 'Main Page' ) )->getPrefixedDBkey(); + } } - $cache = new HTMLFileCache( $t ); - if ( $cache->isFileCached() ) { - return $cache->fetchPageText(); + $cache = HTMLFileCache::newFromTitle( $t, 'view' ); + if ( $cache->isCached() ) { + return $cache->fetchText(); } else { return ''; } @@ -242,15 +260,18 @@ EOT; class DBQueryError extends DBError { public $error, $errno, $sql, $fname; + /** + * @param $db DatabaseBase + * @param $error string + * @param $errno int|string + * @param $sql string + * @param $fname string + */ function __construct( DatabaseBase &$db, $error, $errno, $sql, $fname ) { - $message = "A database error has occurred. Did you forget to run maintenance/update.php after upgrading? See: http://www.mediawiki.org/wiki/Manual:Upgrading#Run_the_update_script\n" . + $message = "A database error has occurred. Did you forget to run maintenance/update.php after upgrading? See: https://www.mediawiki.org/wiki/Manual:Upgrading#Run_the_update_script\n" . "Query: $sql\n" . "Function: $fname\n" . "Error: $errno $error\n"; - global $wgShowDBErrorBacktrace; - if( $wgShowDBErrorBacktrace ) { - $message .= $this->getTraceAsString(); - } parent::__construct( $db, $message ); $this->error = $error; @@ -295,6 +316,9 @@ class DBQueryError extends DBError { } } + /** + * @return bool + */ function getLogMessage() { # Don't send to the exception log return false; |