Error opening language pack (incorrect string value)
If you get an error like this when opening the language pack, it is indicating that your database, database tables (particularly mdl_tool_customlang
) or your config.php
is not using an utf8mb4
collation. For example utf8mb4_general_ci
.
Debug info: Incorrect string value: '\xF0\x9F\x91\x8B' for column 'original' at row 1
INSERT INTO mdl_tool_customlang
(lang,componentid,stringid,original,master,timemodified,outdated,local,timecustomized)
VALUES(?,?,?,?,?,?,?,?,?)
-- line 1408 of /lib/dml/mysqli_native_moodle_database.php:
call to mysqli_native_moodle_database->insert_record_raw()
[array (
0 => 'en',
1 => '1',
2 => 'welcomeback',
3 => 'Welcome back, {$a->firstname}! π',
4 => 'Welcome back, {$a->firstname}! π',
5 => 1685932707,
6 => 0,
7 => NULL,
8 => NULL,
)]
Error code: dmlwriteexception
You can fix the database tables using the tool (e.g.):
admin/cli/ php admin/cli/mysql_collation.php --collation=utf8mb4_general_ci
Don't forget to also set your database to the correct collation.
Finally, you need to check what you have set in config.php
as well e.g.
$CFG->dboptions = array (
'dbpersist' => 0,
'dbport' => '',
'dbsocket' => '',
'dbcollation' => 'utf8mb4_general_ci',
);
If the config.php
file is still using something like utf8
you'll need to update it AND clear the cache. For this to take effect.
No Comments