From c611f88d680586b6d92c77ecef3ea2163fc71488 Mon Sep 17 00:00:00 2001 From: Eileen McNaughton Date: Tue, 20 Jul 2021 12:50:49 +1200 Subject: [PATCH] Fix databaseSupportsUTF8MB4 stripos returns 0 on success, not true. --- CRM/Core/BAO/SchemaHandler.php | 2 +- tests/phpunit/api/v3/ContactTest.php | 18 +----------------- 2 files changed, 2 insertions(+), 18 deletions(-) diff --git a/CRM/Core/BAO/SchemaHandler.php b/CRM/Core/BAO/SchemaHandler.php index cd294c1b5f..2f41ae364c 100644 --- a/CRM/Core/BAO/SchemaHandler.php +++ b/CRM/Core/BAO/SchemaHandler.php @@ -920,7 +920,7 @@ MODIFY {$columnName} varchar( $length ) */ public static function databaseSupportsUTF8MB4(): bool { if (!isset(\Civi::$statics[__CLASS__][__FUNCTION__])) { - \Civi::$statics[__CLASS__][__FUNCTION__] = stripos(self::getInUseCollation(), 'utf8mb4') === TRUE; + \Civi::$statics[__CLASS__][__FUNCTION__] = stripos(self::getInUseCollation(), 'utf8mb4') === 0; } return \Civi::$statics[__CLASS__][__FUNCTION__]; } diff --git a/tests/phpunit/api/v3/ContactTest.php b/tests/phpunit/api/v3/ContactTest.php index 600c34cf7e..79b3e54caf 100644 --- a/tests/phpunit/api/v3/ContactTest.php +++ b/tests/phpunit/api/v3/ContactTest.php @@ -5194,29 +5194,13 @@ class api_v3_ContactTest extends CiviUnitTestCase { * * By default our DBs are not 🦉 compliant. This test will age * out when we are. - * - * @throws \CRM_Core_Exception */ public function testEmojiInWhereClause(): void { - $schemaNeedsAlter = CRM_Core_BAO_SchemaHandler::databaseSupportsUTF8MB4(); - if ($schemaNeedsAlter) { - CRM_Core_DAO::executeQuery(" - ALTER TABLE civicrm_contact MODIFY COLUMN - `first_name` VARCHAR(64) CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL COMMENT 'First Name.', - CHARSET utf8 - "); - } $this->callAPISuccess('Contact', 'get', [ 'debug' => 1, 'first_name' => '🦉Claire', + 'version' => 4, ]); - if ($schemaNeedsAlter) { - CRM_Core_DAO::executeQuery(" - ALTER TABLE civicrm_contact MODIFY COLUMN - `first_name` VARCHAR(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'First Name.', - CHARSET utf8mb4 - "); - } } /** -- 2.25.1