summaryrefslogtreecommitdiff
path: root/includes/db/DatabaseError.php
diff options
context:
space:
mode:
Diffstat (limited to 'includes/db/DatabaseError.php')
-rw-r--r--includes/db/DatabaseError.php22
1 files changed, 11 insertions, 11 deletions
diff --git a/includes/db/DatabaseError.php b/includes/db/DatabaseError.php
index a53a6747..628a2afc 100644
--- a/includes/db/DatabaseError.php
+++ b/includes/db/DatabaseError.php
@@ -35,9 +35,9 @@ class DBError extends MWException {
/**
* Construct a database error
* @param $db DatabaseBase object which threw the error
- * @param $error String A simple error message to be used for debugging
+ * @param string $error A simple error message to be used for debugging
*/
- function __construct( DatabaseBase &$db, $error ) {
+ function __construct( DatabaseBase $db = null, $error ) {
$this->db = $db;
parent::__construct( $error );
}
@@ -91,7 +91,7 @@ class DBError extends MWException {
class DBConnectionError extends DBError {
public $error;
- function __construct( DatabaseBase &$db, $error = 'unknown error' ) {
+ function __construct( DatabaseBase $db = null, $error = 'unknown error' ) {
$msg = 'DB connection error';
if ( trim( $error ) != '' ) {
@@ -153,12 +153,12 @@ class DBConnectionError extends DBError {
$sorry = htmlspecialchars( $this->msg( 'dberr-problems', 'Sorry! This site is experiencing technical difficulties.' ) );
$again = htmlspecialchars( $this->msg( 'dberr-again', 'Try waiting a few minutes and reloading.' ) );
- $info = htmlspecialchars( $this->msg( 'dberr-info', '(Can\'t contact the database server: $1)' ) );
+ $info = htmlspecialchars( $this->msg( 'dberr-info', '(Can\'t contact the database server: $1)' ) );
# No database access
MessageCache::singleton()->disable();
- if ( trim( $this->error ) == '' ) {
+ if ( trim( $this->error ) == '' && $this->db ) {
$this->error = $this->db->getProperty( 'mServer' );
}
@@ -176,7 +176,7 @@ class DBConnectionError extends DBError {
return "$text<hr />$extra";
}
- public function reportHTML(){
+ public function reportHTML() {
global $wgUseFileCache;
# Check whether we can serve a file-cached copy of the page with the error underneath
@@ -288,11 +288,11 @@ class DBQueryError extends DBError {
* @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: https://www.mediawiki.org/wiki/Manual:Upgrading#Run_the_update_script\n" .
- "Query: $sql\n" .
- "Function: $fname\n" .
- "Error: $errno $error\n";
+ 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: https://www.mediawiki.org/wiki/Manual:Upgrading#Run_the_update_script\n" .
+ "Query: $sql\n" .
+ "Function: $fname\n" .
+ "Error: $errno $error\n";
parent::__construct( $db, $message );
$this->error = $error;