Make WordPress Core

Changeset 53919


Ignore:
Timestamp:
08/22/2022 04:40:54 PM (2 years ago)
Author:
SergeyBiryukov
Message:

Tests: Correct MariaDB version check in database charset tests.

MariaDB version is reported differently between PHP versions:

  • PHP 8.0.16 or later: 10.6.8-MariaDB
  • PHP 8.0.15 or earlier: 5.5.5-10.6.8-MariaDB

The latter includes PHP 7.4.x and PHP 5.6.x as well, where the version is also reported with the 5.5.5- prefix.

This commit makes an adjustment to the Tests_DB_Charset class to check for the correct version.

References:

Follow-up to [53918].

Fixes #53623.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/db/charset.php

    r53918 r53919  
    4646        self::$db_version     = self::$_wpdb->db_version();
    4747        self::$db_server_info = self::$_wpdb->db_server_info();
     48
     49        // Account for MariaDB version being prefixed with '5.5.5-' on older PHP versions.
     50        if ( str_contains( self::$db_server_info, 'MariaDB' ) && '5.5.5' === self::$db_version
     51            && PHP_VERSION_ID < 80016 // PHP 8.0.15 or older.
     52        ) {
     53            // Strip the '5.5.5-' prefix and set the version to the correct value.
     54            self::$db_server_info = preg_replace( '/^5\.5\.5-(.*)/', '$1', self::$db_server_info );
     55            self::$db_version     = preg_replace( '/[^0-9.].*/', '', self::$db_server_info );
     56        }
    4857
    4958        /*
Note: See TracChangeset for help on using the changeset viewer.