From 34700cd7fb13d3e0485a21d42da56184263fb9ba Mon Sep 17 00:00:00 2001 From: Andrew Nacin Date: Thu, 3 Apr 2014 04:06:14 +0000 Subject: [PATCH] Database: Add $allow_bail argument to wpdb::check_connection() to match the connect method. props DrProtocols, pento. fixes #27240. Built from https://develop.svn.wordpress.org/trunk@27925 git-svn-id: http://core.svn.wordpress.org/trunk@27755 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/wp-db.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/wp-includes/wp-db.php b/wp-includes/wp-db.php index 170c29565e..8423731e8c 100644 --- a/wp-includes/wp-db.php +++ b/wp-includes/wp-db.php @@ -1386,9 +1386,13 @@ class wpdb { * * @since 3.9.0 * + * @param bool $allow_bail Optional. Allows the function to bail, default true. If this is set + * to false, you will need to handle the lack of database connection + * manually. + * * @return bool True if the connection is up. */ - function check_connection() { + function check_connection( $allow_bail = true ) { if ( $this->use_mysqli ) { if ( @mysqli_ping( $this->dbh ) ) { return true; @@ -1431,6 +1435,10 @@ class wpdb { return false; } + if ( ! $allow_bail ) { + return false; + } + // We weren't able to reconnect, so we better bail. $this->bail( sprintf( ( "

Error reconnecting to the database