Skip to content

[2.1] Upgrader - Set db_character_set#9278

Open
sbulen wants to merge 1 commit into
SimpleMachines:release-2.1from
sbulen:21_upgr_charset_collation
Open

[2.1] Upgrader - Set db_character_set#9278
sbulen wants to merge 1 commit into
SimpleMachines:release-2.1from
sbulen:21_upgr_charset_collation

Conversation

@sbulen

@sbulen sbulen commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

Spun off from #9271

Mid-upgrade, $db_character_set was getting erroneously set to 'utf8' in step 2 under some circumstances. So, if there were non-utf8 characters, updates to that data could mangle or delete the data. This is mostly visible during the json conversion, where lots of latin1 characters may be encountered. Both MySQL & MariaDB are affected.

In 2.0, $db_character_set was not set by the SMF installer. So it's blank for a lot of forums. The 2.1 upgrader, when the 'Migrate to new Settings.php' box is checked, detects the blank $db_character_set and defaults it to 'utf8'. This causes the upgrader to issue a SET NAMES for 'utf8'. Database updates prior to the utf8 conversion could cause issues.

So, this PR detects what $db_character_set should be, then sets it in Settings.php. That way the Settings.php migration leaves it alone. It is then properly set to 'utf8' in a later step, after the utf8 conversion completes.

If approved, I'll work on a 3.0 version.

Note there is still one odd wrinkle related to charsets/collations I haven't figured out... During the utf8 conversion, MariaDB is setting all the tables to utf8mb3_uca1400_ai_ci instead of utf8mb3_general_ci, the SMF 2.1 default. They are not synonymous. Haven't figured out why yet.

Signed-off-by: Shawn Bulen <bulens@pacbell.net>
@sbulen

sbulen commented Jun 27, 2026

Copy link
Copy Markdown
Contributor Author

Some screenshots....

This is a screenshot of the serialized strings in log_actions before the upgrade:

log_actions_before

Log actions after the upgrade... Items with non-utf8 chars were lost:

log_actions_after

With this PR, the characters are maintained:

log_actions_after_fix

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant