From 1da3c94e5568bae7dee0325af85dc1e52c813ade Mon Sep 17 00:00:00 2001 From: Peter Westwood Date: Thu, 14 Oct 2010 18:47:39 +0000 Subject: [PATCH] Display mysql_connect errors when WP_DEBUG is enabled. Fixes #14654 props lloydbudd and hakre Always die if we can't connect to the db no point in going any futher. git-svn-id: https://develop.svn.wordpress.org/trunk@15808 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-includes/wp-db.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/wp-includes/wp-db.php b/wp-includes/wp-db.php index 1f6228434e..cd01e7097d 100644 --- a/wp-includes/wp-db.php +++ b/wp-includes/wp-db.php @@ -1026,7 +1026,11 @@ class wpdb { function db_connect() { global $db_list, $global_db_list; - $this->dbh = @mysql_connect( $this->dbhost, $this->dbuser, $this->dbpassword, true ); + if ( WP_DEBUG ) { + $this->dbh = mysql_connect( $this->dbhost, $this->dbuser, $this->dbpassword, true ); + } else { + $this->dbh = @mysql_connect( $this->dbhost, $this->dbuser, $this->dbpassword, true ); + } if ( !$this->dbh ) { $this->bail( sprintf( /*WP_I18N_DB_CONN_ERROR*/" @@ -1039,6 +1043,9 @@ class wpdb {

If you're unsure what these terms mean you should probably contact your host. If you still need help you can always visit the WordPress Support Forums.

"/*/WP_I18N_DB_CONN_ERROR*/, $this->dbhost ), 'db_connect_fail' ); + + //If show errors is disabled then we need to die anyway as we don't have a working DB connection + die(); } $this->set_charset( $this->dbh );