WPDB: Always use `mysqli` when available.

This change makes WordPress use `mysqli` on PHP <5.5 when available, instead of only in PHP 5.5+ and development installs.

WPDB includes a fallback to `mysql` in the event that the database connection fails with `mysqli` so incompatibilities should be few and far between.

Fixes #42812 for trunk.


git-svn-id: https://develop.svn.wordpress.org/trunk@42388 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Dion Hulse 2017-12-12 05:42:12 +00:00
parent da689558a5
commit f216215864
1 changed files with 3 additions and 10 deletions

View File

@ -593,19 +593,12 @@ class wpdb {
$this->show_errors();
}
/* Use ext/mysqli if it exists and:
* - WP_USE_EXT_MYSQL is defined as false, or
* - We are a development version of WordPress, or
* - We are running PHP 5.5 or greater, or
* - ext/mysql is not loaded.
*/
// Use ext/mysqli if it exists unless WP_USE_EXT_MYSQL is defined as true
if ( function_exists( 'mysqli_connect' ) ) {
$this->use_mysqli = true;
if ( defined( 'WP_USE_EXT_MYSQL' ) ) {
$this->use_mysqli = ! WP_USE_EXT_MYSQL;
} elseif ( version_compare( phpversion(), '5.5', '>=' ) || ! function_exists( 'mysql_connect' ) ) {
$this->use_mysqli = true;
} elseif ( false !== strpos( $GLOBALS['wp_version'], '-' ) ) {
$this->use_mysqli = true;
}
}