From ed89bf373116ae282d04744aebe05600fde66ae7 Mon Sep 17 00:00:00 2001 From: Adam Daley Date: Sun, 21 Jun 2026 18:49:00 +0200 Subject: [PATCH] Fix MySQL 8.0.22+ REGEXP charset conflict in patches 67 and 74 (#3822) * Fix MySQL 8.0.22+ REGEXP charset conflict in patches 67 and 74 MySQL 8.0.22+ changed the REGEXP implementation to use ICU internals, which rejects operands with mismatched character sets. Using `BINARY hash` (producing binary charset) alongside a pattern literal with the session charset (e.g. utf8mb3_general_ci) triggers: SQLSTATE[HY000]: General error: 3995 Character set 'binary' cannot be used in conjunction with 'utf8mb3_general_ci' in call to regexp_like. Replace `BINARY hash NOT REGEXP '^[a-f0-9]+$'` in both patches with `CAST(hash AS BINARY) NOT REGEXP _binary'^[a-f0-9]+$'`, making both operands explicitly binary. This preserves the original case-sensitive matching behaviour while being compatible with MySQL 8.0+ and MariaDB. Co-Authored-By: Claude Sonnet 4.6 Claude-Session: https://claude.ai/code/session_01PNZCQ7v3gm6fc6t98TyZGP * Fix invoice hash regexp charset handling --------- Co-authored-by: Claude --- src/library/FOSSBilling/UpdatePatcher.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/library/FOSSBilling/UpdatePatcher.php b/src/library/FOSSBilling/UpdatePatcher.php index 217fda6e6..34f7a5ecc 100644 --- a/src/library/FOSSBilling/UpdatePatcher.php +++ b/src/library/FOSSBilling/UpdatePatcher.php @@ -1504,7 +1504,7 @@ class UpdatePatcher implements InjectionAwareInterface $expires = $this->computeInvoiceHashExpiration(); $rows = $this->fetchAll( "SELECT id FROM invoice WHERE hash IS NOT NULL - AND (LENGTH(hash) < 30 OR LENGTH(hash) > 60 OR BINARY hash NOT REGEXP '^[a-f0-9]+$')" + AND (LENGTH(hash) < 30 OR LENGTH(hash) > 60 OR CONVERT(hash USING utf8mb4) COLLATE utf8mb4_bin NOT REGEXP '^[a-f0-9]+$')" ); foreach ($rows as $row) { $this->executeSql( @@ -1879,7 +1879,7 @@ class UpdatePatcher implements InjectionAwareInterface // Backfill hashes NULLed by the original revision of patch67. $expires = $this->computeInvoiceHashExpiration(); $rows = $this->fetchAll( - "SELECT id FROM invoice WHERE hash IS NULL OR LENGTH(hash) < 30 OR LENGTH(hash) > 60 OR BINARY hash NOT REGEXP '^[a-f0-9]+$'" + "SELECT id FROM invoice WHERE hash IS NULL OR LENGTH(hash) < 30 OR LENGTH(hash) > 60 OR CONVERT(hash USING utf8mb4) COLLATE utf8mb4_bin NOT REGEXP '^[a-f0-9]+$'" ); foreach ($rows as $row) { $this->executeSql(