diff --git a/wp-content/db.php b/wp-content/db.php
index abc3353e744143f332e057495f51811d40ae80c8..0f9f5a1ee205f4a80d5ef5b2ffa225efa0217781 100644
--- a/wp-content/db.php
+++ b/wp-content/db.php
@@ -55,7 +55,7 @@ define( 'HYPERDB_SERVER_GONE_ERROR', 2006 ); // MySQL server has gone away
 class hyperdb extends wpdb {
 
         /**
-	 * A/I patch! 
+	 * A/I patch!
 	 * store a FlexiHash() instance here.
 	 */
 	var $hash_map;
@@ -680,16 +680,19 @@ class hyperdb extends wpdb {
 				$success = false;
 				$this->last_connection = compact('dbhname', 'host', 'port', 'user', 'name', 'tcp', 'elapsed', 'success');
 				$this->db_connections[] = $this->last_connection;
-				$msg = date( "Y-m-d H:i:s" ) . " Can't select $dbhname - \n";
-				$msg .= "'referrer' => '{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}',\n";
-				$msg .= "'server' => {$server},\n";
-				$msg .= "'host' => {$host},\n";
-				$msg .= "'error' => " . $this->ex_mysql_error() . ",\n";
-				$msg .= "'errno' => " . $this->ex_mysql_errno() . ",\n";
-				$msg .= "'server_state' => $server_state\n";
-				$msg .= "'lagged_status' => " . ( isset( $lagged_status ) ? $lagged_status : HYPERDB_LAG_UNKNOWN );
-
-				$this->print_error( $msg );
+                /* Workaround to stop logging a/i */
+                if ( AI_LOG_HYPERDB == true ) {
+                    $msg = date( "Y-m-d H:i:s" ) . " Can't select $dbhname - \n";
+                    $msg .= "'referrer' => '{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}',\n";
+                    $msg .= "'server' => {$server},\n";
+                    $msg .= "'host' => {$host},\n";
+                    $msg .= "'error' => " . $this->ex_mysql_error() . ",\n";
+                    $msg .= "'errno' => " . $this->ex_mysql_errno() . ",\n";
+                    $msg .= "'server_state' => $server_state\n";
+                    $msg .= "'lagged_status' => " . ( isset( $lagged_status ) ? $lagged_status : HYPERDB_LAG_UNKNOWN );
+
+                    $this->print_error( $msg );
+                }
 			}
 
 			if ( ! $success || ! isset( $this->dbhs[$dbhname] ) || ! $this->is_mysql_connection( $this->dbhs[$dbhname] ) ) {
@@ -723,8 +726,8 @@ class hyperdb extends wpdb {
 			$collate = null;
 
 		$this->set_charset($this->dbhs[$dbhname], $charset, $collate);
-		
-		if ( !isset( $charset ) ) 
+
+		if ( !isset( $charset ) )
 			$charset = null;
 
 		if ( !isset( $collate ) )
@@ -885,7 +888,7 @@ class hyperdb extends wpdb {
             if (strpos($_SERVER['REQUEST_URI'], '/wp-admin/') !== false) {
                 $query .= ' /* NO CACHE */';
             }
-            
+
 			$this->timer_start();
 			if ( $statement_before_query ) {
 				$query_for_log = "$statement_before_query; $query_for_log";