From 59123b5b24e0aefea60a0fb4ab1cf8c534014a50 Mon Sep 17 00:00:00 2001 From: Gary Pendergast Date: Fri, 22 Apr 2016 05:24:29 +0000 Subject: [PATCH] Database: Suppress connection error messages when `WP_DEBUG` isn't enabled. This is a partial revert of [35860], which has been causing un-catchable warnings to be generated on some server configurations. Merge of [37292] to the 4.5 branch. Fixes #36629. See #21870. Built from https://develop.svn.wordpress.org/branches/4.5@37293 git-svn-id: http://core.svn.wordpress.org/branches/4.5@37259 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/version.php | 2 +- wp-includes/wp-db.php | 12 ++++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/wp-includes/version.php b/wp-includes/version.php index a41550ff56..9715346864 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @global string $wp_version */ -$wp_version = '4.5.1-RC-37291'; +$wp_version = '4.5.1-RC-37293'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema. diff --git a/wp-includes/wp-db.php b/wp-includes/wp-db.php index 22cd943018..066e851fa3 100644 --- a/wp-includes/wp-db.php +++ b/wp-includes/wp-db.php @@ -1486,7 +1486,11 @@ class wpdb { } } - mysqli_real_connect( $this->dbh, $host, $this->dbuser, $this->dbpassword, null, $port, $socket, $client_flags ); + if ( WP_DEBUG ) { + mysqli_real_connect( $this->dbh, $host, $this->dbuser, $this->dbpassword, null, $port, $socket, $client_flags ); + } else { + @mysqli_real_connect( $this->dbh, $host, $this->dbuser, $this->dbpassword, null, $port, $socket, $client_flags ); + } if ( $this->dbh->connect_errno ) { $this->dbh = null; @@ -1512,7 +1516,11 @@ class wpdb { } } } else { - $this->dbh = mysql_connect( $this->dbhost, $this->dbuser, $this->dbpassword, $new_link, $client_flags ); + if ( WP_DEBUG ) { + $this->dbh = mysql_connect( $this->dbhost, $this->dbuser, $this->dbpassword, $new_link, $client_flags ); + } else { + $this->dbh = @mysql_connect( $this->dbhost, $this->dbuser, $this->dbpassword, $new_link, $client_flags ); + } } if ( ! $this->dbh && $allow_bail ) {