Make WordPress Core


Ignore:
Timestamp:
04/04/2024 03:11:37 PM (12 months ago)
Author:
johnbillion
Message:

Database: Remove back-compat for database servers that don't support utf8mb4.

Since WordPress 6.5, the minimum supported version of MySQL and MariaDB is 5.5.5. This means all supported database servers now support the utf8mb4 character set and therefore the conditional logic for this is no longer necessary.

Props l1nuxjedi, craigfrancis, OllieJones, johnbillion

Fixes #60096

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/class-wpdb.php

    r57239 r57926  
    879879        }
    880880
    881         if ( 'utf8' === $charset && $this->has_cap( 'utf8mb4' ) ) {
     881        if ( 'utf8' === $charset ) {
    882882            $charset = 'utf8mb4';
    883         }
    884 
    885         if ( 'utf8mb4' === $charset && ! $this->has_cap( 'utf8mb4' ) ) {
    886             $charset = 'utf8';
    887             $collate = str_replace( 'utf8mb4_', 'utf8_', $collate );
    888883        }
    889884
     
    32433238                list( $charset ) = explode( '_', $column->Collation );
    32443239
    3245                 // If the current connection can't support utf8mb4 characters, let's only send 3-byte utf8 characters.
    3246                 if ( 'utf8mb4' === $charset && ! $this->has_cap( 'utf8mb4' ) ) {
    3247                     $charset = 'utf8';
    3248                 }
    3249 
    32503240                $charsets[ strtolower( $charset ) ] = true;
    32513241            }
     
    40584048     * @since 4.6.0 Added support for the 'utf8mb4_520' feature.
    40594049     * @since 6.2.0 Added support for the 'identifier_placeholders' feature.
     4050     * @since 6.6.0 The `utf8mb4` feature now always returns true.
    40604051     *
    40614052     * @see wpdb::db_version()
     
    40934084                return version_compare( $db_version, '5.0.7', '>=' );
    40944085            case 'utf8mb4':      // @since 4.1.0
    4095                 if ( version_compare( $db_version, '5.5.3', '<' ) ) {
    4096                     return false;
    4097                 }
    4098 
    4099                 $client_version = mysqli_get_client_info();
    4100 
    4101                 /*
    4102                  * libmysql has supported utf8mb4 since 5.5.3, same as the MySQL server.
    4103                  * mysqlnd has supported utf8mb4 since 5.0.9.
    4104                  *
    4105                  * Note: str_contains() is not used here, as this file can be included
    4106                  * directly outside of WordPress core, e.g. by HyperDB, in which case
    4107                  * the polyfills from wp-includes/compat.php are not loaded.
    4108                  */
    4109                 if ( false !== strpos( $client_version, 'mysqlnd' ) ) {
    4110                     $client_version = preg_replace( '/^\D+([\d.]+).*/', '$1', $client_version );
    4111                     return version_compare( $client_version, '5.0.9', '>=' );
    4112                 } else {
    4113                     return version_compare( $client_version, '5.5.3', '>=' );
    4114                 }
     4086                return true;
    41154087            case 'utf8mb4_520': // @since 4.6.0
    41164088                return version_compare( $db_version, '5.6', '>=' );
Note: See TracChangeset for help on using the changeset viewer.