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. Props dd32. Merges [42388] to the 4.9 branch. Fixes #42812. Built from https://develop.svn.wordpress.org/branches/4.9@42455 git-svn-id: http://core.svn.wordpress.org/branches/4.9@42284 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
84bd75ea88
commit
b6d9609fa9
|
@ -570,19 +570,12 @@ class wpdb {
|
||||||
if ( WP_DEBUG && WP_DEBUG_DISPLAY )
|
if ( WP_DEBUG && WP_DEBUG_DISPLAY )
|
||||||
$this->show_errors();
|
$this->show_errors();
|
||||||
|
|
||||||
/* Use ext/mysqli if it exists and:
|
// Use ext/mysqli if it exists unless WP_USE_EXT_MYSQL is defined as true
|
||||||
* - 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.
|
|
||||||
*/
|
|
||||||
if ( function_exists( 'mysqli_connect' ) ) {
|
if ( function_exists( 'mysqli_connect' ) ) {
|
||||||
|
$this->use_mysqli = true;
|
||||||
|
|
||||||
if ( defined( 'WP_USE_EXT_MYSQL' ) ) {
|
if ( defined( 'WP_USE_EXT_MYSQL' ) ) {
|
||||||
$this->use_mysqli = ! 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;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue