Duplicate Unable to convert tables to utf8mb4 after upgrading to XF2 on MariaDB 10.7

Jake B.

Well-known member
Affected version
2.2.12
Code:
root@web1:~# mysql --version
mysql  Ver 15.1 Distrib 10.7.6-MariaDB, for debian-linux-gnu (x86_64) using readline 5.2

Code:
MariaDB [***]> show full columns from xf_post;
+-------------------------+---------------------------------------+--------------------+------+-----+---------+----------------+---------------------------------+---------+
| Field                   | Type                                  | Collation          | Null | Key | Default | Extra          | Privileges                      | Comment |
+-------------------------+---------------------------------------+--------------------+------+-----+---------+----------------+---------------------------------+---------+
[...]
| message                 | mediumtext                            | utf8mb3_general_ci | NO   |     | NULL    |                | select,insert,update,references |         |
[...]

It looks like these tables are using utf8mb3_general_ci while XenForo is expecting utf8_general_ci during the conversion. From what I can tell this likely also happens on MySQL 8.0.30+ as well: https://dev.mysql.com/doc/relnotes/connector-cpp/en/news-8-0-30.html

Collation names returned by the CollationInfo::getName() method for CollationInfo members in Collation<21> have changed. For example, Collation<21>::general_ci.getName() now returns “utf8mb3_general_ci” instead of “utf8_general_ci”.

It seems applying this patch resolves the issue:

Diff:
diff --git a/src/XF/Cli/Command/ConvertUtf8mb4.php b/src/XF/Cli/Command/ConvertUtf8mb4.php
index fe4196eed..ea366dbb4 100644
--- a/src/XF/Cli/Command/ConvertUtf8mb4.php
+++ b/src/XF/Cli/Command/ConvertUtf8mb4.php
@@ -63,7 +63,7 @@ class ConvertUtf8mb4 extends Command
 				continue;
 			}
 
-			if (!preg_match('/^utf8_/', $table['Collation']))
+			if (!preg_match('/^utf8_/', $table['Collation']) && !preg_match('/^utf8mb3_/', $table['Collation']))
 			{
 				continue;
 			}
 
Well, technically this is two separate issues related to the same thing. There's the mismatch detection and the command not working. We'll track both things in the same report though.
 
Back
Top Bottom