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
This commit is contained in:
Andrew Nacin 2014-04-03 04:06:14 +00:00
parent 1c3cc50496
commit 34700cd7fb
1 changed files with 9 additions and 1 deletions

View File

@ -1386,9 +1386,13 @@ class wpdb {
* *
* @since 3.9.0 * @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. * @return bool True if the connection is up.
*/ */
function check_connection() { function check_connection( $allow_bail = true ) {
if ( $this->use_mysqli ) { if ( $this->use_mysqli ) {
if ( @mysqli_ping( $this->dbh ) ) { if ( @mysqli_ping( $this->dbh ) ) {
return true; return true;
@ -1431,6 +1435,10 @@ class wpdb {
return false; return false;
} }
if ( ! $allow_bail ) {
return false;
}
// We weren't able to reconnect, so we better bail. // We weren't able to reconnect, so we better bail.
$this->bail( sprintf( ( " $this->bail( sprintf( ( "
<h1>Error reconnecting to the database</h1> <h1>Error reconnecting to the database</h1>