Make WordPress Core

Changeset 42455


Ignore:
Timestamp:
01/15/2018 10:49:15 PM (7 years ago)
Author:
SergeyBiryukov
Message:

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.

Location:
branches/4.9
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/4.9

  • branches/4.9/src/wp-includes/wp-db.php

    r42229 r42455  
    571571            $this->show_errors();
    572572
    573         /* Use ext/mysqli if it exists and:
    574          *  - WP_USE_EXT_MYSQL is defined as false, or
    575          *  - We are a development version of WordPress, or
    576          *  - We are running PHP 5.5 or greater, or
    577          *  - ext/mysql is not loaded.
    578          */
     573        // Use ext/mysqli if it exists unless WP_USE_EXT_MYSQL is defined as true
    579574        if ( function_exists( 'mysqli_connect' ) ) {
     575            $this->use_mysqli = true;
     576
    580577            if ( defined( 'WP_USE_EXT_MYSQL' ) ) {
    581578                $this->use_mysqli = ! WP_USE_EXT_MYSQL;
    582             } elseif ( version_compare( phpversion(), '5.5', '>=' ) || ! function_exists( 'mysql_connect' ) ) {
    583                 $this->use_mysqli = true;
    584             } elseif ( false !== strpos( $GLOBALS['wp_version'], '-' ) ) {
    585                 $this->use_mysqli = true;
    586579            }
    587580        }
Note: See TracChangeset for help on using the changeset viewer.