From 1494cd61de7b86833d64a616d71513929d9df63d Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Sun, 8 Aug 2004 01:07:56 +0000 Subject: [PATCH] Report the database connection failure error message when no server can be contacted instead of silently ignoring it and dying when unable to use 'false' as an array index. --- includes/LoadBalancer.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/includes/LoadBalancer.php b/includes/LoadBalancer.php index 455844c71d..fed5fc9129 100644 --- a/includes/LoadBalancer.php +++ b/includes/LoadBalancer.php @@ -190,7 +190,7 @@ class LoadBalancer { } # Get a connection by index - function &getConnection( $i, $fail = false ) + function &getConnection( $i, $fail = true ) { $fname = "LoadBalancer::getConnection"; wfProfileIn( $fname ); @@ -260,6 +260,9 @@ class LoadBalancer { # Test if the specified index represents an open connection /* private */ function isOpen( $index ) { + if( !is_integer( $index ) ) { + return false; + } if ( array_key_exists( $index, $this->mConnections ) && is_object( $this->mConnections[$index] ) && $this->mConnections[$index]->isOpen() ) { @@ -295,9 +298,9 @@ class LoadBalancer { $conn = new Database; } if ( $this->mFailFunction ) { - $conn->setFailFunction( $this->mFailFunction ); + $conn->failFunction( $this->mFailFunction ); } else { - $conn->setFailFunction( "wfEmergencyAbort" ); + $conn->failFunction( "wfEmergencyAbort" ); } $conn->reportConnectionError(); $reporting = false; -- 2.20.1