-
Notifications
You must be signed in to change notification settings - Fork 3
Description
Hello!
We have recently upgraded our MariaDB backend, which the sqlattribs module uses for getting user attributes.
It turned out that this major version upgrade introduced breakage inside the module, at an entirely unexpected place:
| $db->exec("SET NAMES 'utf8'"); |
Not being in-depth into MariaDB, my understanding is that there used to be a default encoding for UTF-8 which used three bytes (utf8mb3) but that default changed in 11 towards a (more proper) four-byte representation, utf8mb4. As it is an upgrade, the existing DB remained on utf8mb3.
The concrete error we got was not on the referenced statement, which seemed to go okay, but on a subsequent query:
Caused by: SimpleSAML\Error\Exception: AttributeFromSQL: execute(value1, value2) failed: SQLSTATE[HY000]: General error: 1267 Illegal mix of collations (utf8mb3_general_ci,COERCIBLE) and (utf8mb3_uca1400_ai_ci,COERCIBLE) for operation '='
uca1400_ai_ci ? Nothing I've ever heard of.
What I can say is that the fix was a patch to the referenced line:
$db->exec("SET NAMES 'utf8'");
+$db->exec("SET NAMES 'utf8' COLLATE 'utf8mb3_general_ci'");
Not sure what the way forward here is. Adding a conditional check in the module to catch such utter weirdness? Or rather change our collations to utfmb4 so that it matches the default? Maybe the module documentation should have some advice in that regards.