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-admin/includes/class-wp-site-health.php

    r57793 r57926  
    12851285
    12861286    /**
    1287      * Tests if the database server is capable of using utf8mb4.
    1288      *
    1289      * @since 5.2.0
    1290      *
    1291      * @return array The test results.
    1292      */
    1293     public function get_test_utf8mb4_support() {
    1294         if ( ! $this->mysql_server_version ) {
    1295             $this->prepare_sql_data();
    1296         }
    1297 
    1298         $result = array(
    1299             'label'       => __( 'UTF8MB4 is supported' ),
    1300             'status'      => 'good',
    1301             'badge'       => array(
    1302                 'label' => __( 'Performance' ),
    1303                 'color' => 'blue',
    1304             ),
    1305             'description' => sprintf(
    1306                 '<p>%s</p>',
    1307                 __( 'UTF8MB4 is the character set WordPress prefers for database storage because it safely supports the widest set of characters and encodings, including Emoji, enabling better support for non-English languages.' )
    1308             ),
    1309             'actions'     => '',
    1310             'test'        => 'utf8mb4_support',
    1311         );
    1312 
    1313         if ( ! $this->is_mariadb ) {
    1314             if ( version_compare( $this->mysql_server_version, '5.5.3', '<' ) ) {
    1315                 $result['status'] = 'recommended';
    1316 
    1317                 $result['label'] = __( 'utf8mb4 requires a MySQL update' );
    1318 
    1319                 $result['description'] .= sprintf(
    1320                     '<p>%s</p>',
    1321                     sprintf(
    1322                         /* translators: %s: Version number. */
    1323                         __( 'WordPress&#8217; utf8mb4 support requires MySQL version %s or greater. Please contact your server administrator.' ),
    1324                         '5.5.3'
    1325                     )
    1326                 );
    1327             } else {
    1328                 $result['description'] .= sprintf(
    1329                     '<p>%s</p>',
    1330                     __( 'Your MySQL version supports utf8mb4.' )
    1331                 );
    1332             }
    1333         } else { // MariaDB introduced utf8mb4 support in 5.5.0.
    1334             if ( version_compare( $this->mysql_server_version, '5.5.0', '<' ) ) {
    1335                 $result['status'] = 'recommended';
    1336 
    1337                 $result['label'] = __( 'utf8mb4 requires a MariaDB update' );
    1338 
    1339                 $result['description'] .= sprintf(
    1340                     '<p>%s</p>',
    1341                     sprintf(
    1342                         /* translators: %s: Version number. */
    1343                         __( 'WordPress&#8217; utf8mb4 support requires MariaDB version %s or greater. Please contact your server administrator.' ),
    1344                         '5.5.0'
    1345                     )
    1346                 );
    1347             } else {
    1348                 $result['description'] .= sprintf(
    1349                     '<p>%s</p>',
    1350                     __( 'Your MariaDB version supports utf8mb4.' )
    1351                 );
    1352             }
    1353         }
    1354 
    1355         // phpcs:ignore WordPress.DB.RestrictedFunctions.mysql_mysqli_get_client_info
    1356         $mysql_client_version = mysqli_get_client_info();
    1357 
    1358         /*
    1359          * libmysql has supported utf8mb4 since 5.5.3, same as the MySQL server.
    1360          * mysqlnd has supported utf8mb4 since 5.0.9.
    1361          */
    1362         if ( str_contains( $mysql_client_version, 'mysqlnd' ) ) {
    1363             $mysql_client_version = preg_replace( '/^\D+([\d.]+).*/', '$1', $mysql_client_version );
    1364             if ( version_compare( $mysql_client_version, '5.0.9', '<' ) ) {
    1365                 $result['status'] = 'recommended';
    1366 
    1367                 $result['label'] = __( 'utf8mb4 requires a newer client library' );
    1368 
    1369                 $result['description'] .= sprintf(
    1370                     '<p>%s</p>',
    1371                     sprintf(
    1372                         /* translators: 1: Name of the library, 2: Number of version. */
    1373                         __( 'WordPress&#8217; utf8mb4 support requires MySQL client library (%1$s) version %2$s or newer. Please contact your server administrator.' ),
    1374                         'mysqlnd',
    1375                         '5.0.9'
    1376                     )
    1377                 );
    1378             }
    1379         } else {
    1380             if ( version_compare( $mysql_client_version, '5.5.3', '<' ) ) {
    1381                 $result['status'] = 'recommended';
    1382 
    1383                 $result['label'] = __( 'utf8mb4 requires a newer client library' );
    1384 
    1385                 $result['description'] .= sprintf(
    1386                     '<p>%s</p>',
    1387                     sprintf(
    1388                         /* translators: 1: Name of the library, 2: Number of version. */
    1389                         __( 'WordPress&#8217; utf8mb4 support requires MySQL client library (%1$s) version %2$s or newer. Please contact your server administrator.' ),
    1390                         'libmysql',
    1391                         '5.5.3'
    1392                     )
    1393                 );
    1394             }
    1395         }
    1396 
    1397         return $result;
    1398     }
    1399 
    1400     /**
    14011287     * Tests if the site can communicate with WordPress.org.
    14021288     *
     
    27402626                    'test'  => 'sql_server',
    27412627                ),
    2742                 'utf8mb4_support'              => array(
    2743                     'label' => __( 'MySQL utf8mb4 support' ),
    2744                     'test'  => 'utf8mb4_support',
    2745                 ),
    27462628                'ssl_support'                  => array(
    27472629                    'label' => __( 'Secure communication' ),
Note: See TracChangeset for help on using the changeset viewer.