mirror of
https://github.com/WordPress/WordPress.git
synced 2024-12-23 01:27:36 +01:00
Database: Correct MariaDB version check in wpdb::has_cap()
.
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 `wpdb::has_cap()` to check for the correct MariaDB version. This resolves an issue where the `utf8mb4_unicode_520_ci` collation, which is available in MariaDB since version 10.2, was previously not detected correctly. References: * [https://github.com/php/php-src/issues/7972 php-src: #7972: MariaDB version prefix 5.5.5- is not stripped] * [https://github.com/php/php-src/pull/7963 php-src: PR #7963 Fix GH-7932: MariaDB version prefix not always stripped] * [https://mariadb.com/docs/reference/mdb/collations/utf8mb4_unicode_520_ci/ MariaDB Documentation: utf8mb4_unicode_520_ci] Follow-up to [37523], [53919]. Props jamieburchell, SergeyBiryukov. Fixes #54841. Built from https://develop.svn.wordpress.org/trunk@54384 git-svn-id: http://core.svn.wordpress.org/trunk@53943 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
4de88db482
commit
2ede19910a
@ -3960,17 +3960,27 @@ class wpdb {
|
||||
* @return bool True when the database feature is supported, false otherwise.
|
||||
*/
|
||||
public function has_cap( $db_cap ) {
|
||||
$version = $this->db_version();
|
||||
$db_version = $this->db_version();
|
||||
$db_server_info = $this->db_server_info();
|
||||
|
||||
// Account for MariaDB version being prefixed with '5.5.5-' on older PHP versions.
|
||||
if ( '5.5.5' === $db_version && str_contains( $db_server_info, 'MariaDB' )
|
||||
&& PHP_VERSION_ID < 80016 // PHP 8.0.15 or older.
|
||||
) {
|
||||
// Strip the '5.5.5-' prefix and set the version to the correct value.
|
||||
$db_server_info = preg_replace( '/^5\.5\.5-(.*)/', '$1', $db_server_info );
|
||||
$db_version = preg_replace( '/[^0-9.].*/', '', $db_server_info );
|
||||
}
|
||||
|
||||
switch ( strtolower( $db_cap ) ) {
|
||||
case 'collation': // @since 2.5.0
|
||||
case 'group_concat': // @since 2.7.0
|
||||
case 'subqueries': // @since 2.7.0
|
||||
return version_compare( $version, '4.1', '>=' );
|
||||
return version_compare( $db_version, '4.1', '>=' );
|
||||
case 'set_charset':
|
||||
return version_compare( $version, '5.0.7', '>=' );
|
||||
return version_compare( $db_version, '5.0.7', '>=' );
|
||||
case 'utf8mb4': // @since 4.1.0
|
||||
if ( version_compare( $version, '5.5.3', '<' ) ) {
|
||||
if ( version_compare( $db_version, '5.5.3', '<' ) ) {
|
||||
return false;
|
||||
}
|
||||
if ( $this->use_mysqli ) {
|
||||
@ -3990,7 +4000,7 @@ class wpdb {
|
||||
return version_compare( $client_version, '5.5.3', '>=' );
|
||||
}
|
||||
case 'utf8mb4_520': // @since 4.6.0
|
||||
return version_compare( $version, '5.6', '>=' );
|
||||
return version_compare( $db_version, '5.6', '>=' );
|
||||
case 'identifier_placeholders': // @since 6.1.0
|
||||
/*
|
||||
* As of WordPress 6.1, wpdb::prepare() supports identifiers via '%i',
|
||||
|
@ -16,7 +16,7 @@
|
||||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '6.1-beta2-54383';
|
||||
$wp_version = '6.1-beta2-54384';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
Loading…
Reference in New Issue
Block a user