You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[2.1.8]: upgrade.php: typo 'ukranian' in $lang_charsets, Ukrainian 2.0 forums converted as ISO-8859-1 instead of windows-1251 #9786
Still present in 2.1.8: other/upgrade.php has 'ukranian' => 'windows-1251' in $lang_charsets. A forum using the correctly spelled ukrainian language (e.g. from 2.0.x packs, file names index.ukrainian.php) isn't matched, so the detected source charset falls back to ISO-8859-1, and the 2.0 → 2.1 UTF-8 conversion corrupts Cyrillic data (cp1251 bytes treated as latin1). The web upgrader offers no way to choose the charset. Suggest listing both spellings (ukrainian and ukranian) as windows-1251.
Steps to reproduce
Take an SMF 2.0.x forum whose default language is "ukrainian" (index.ukrainian.php), with Cyrillic text stored as windows-1251 bytes in latin1-declared tables.
Run upgrade.php from the 2.1.8 "Large upgrade" package (web or CLI).
The "Convert to UTF-8" step runs without asking for the source charset.
Check any Cyrillic subject/post: it is garbled (e.g. "dzðêîâ³ â³éíè").
Before the upgrade the tables were `latin1` (DEFAULT CHARSET=latin1,
latin1_swedish_ci).
The text inside was windows-1251 bytes (the forum used a windows-1251
Ukrainian language pack).
2. Do you have an entry in Settings.php for $db_character_set? If so,
what's the value?
The original Settings.php had no `$db_character_set`. For my test upgrades
I added `latin1`; after the upgrade it was `utf8` (later commented out,
both work).
3. Do you have an entry in the smf_settings table for
global_character_set? If so, what's the value?
No, before upgrade this value wasn’t specified either.
After upgrade, because of the missing `global_character_set` row, board
descriptions were mangled until I inserted `global_character_set = 'UTF-8'`
by hand (bytes 0x82/0x84/0x85 were replaced by `sanitizeMSCutPaste()`).
4. One last question: Did you copy the 2.1 Ukrainian language package
over before the upgrade?
No, I did not copy the 2.1 Ukrainian package before the upgrade; the
upgrader only warned about outdated `ukrainian` language files and I
continued.
-------------------
An error in the name of the Ukrainian language is present in updates 2.1.7
and 2.1.8 in upgrade.php; i have not checked other versions.
now: 'ukranian' => 'windows-1251',
it should be indicated as: 'ukrainian' => 'windows-1251',
I think the issue is even more fundamental than that...
Do we really know the DB charset by looking at the language?
I think the problem they were trying to solve was that, back in the day, different charsets were stuffed into latin1 - it was treated as binary. Querying the DB you'd see latin1. But to do the conversion properly, you'd need to know what charset was stuffed into that latin1.
Note it should never use $txt['lang_character_set']... To properly use a non-English language during the upgrade, you'd need to install the 2.1 language pack for that language. In 2.1, that will always point to 'UTF-8', which is not helpful.
It shouldn't be using charset_detected, because it's not set yet. It shouldn't be using lang_character_set either, because in 2.1 that will always be 'UTF-8', and will never tell us where we're moving FROM.
That logic is trying to make sure that you can do lookups in both $charsets and $lang_charsets based on the forum's primary language from Settings.php, $language.
It's a two-level lookup... $lang_charsets translate from $language to encodings... $charsets translates from encodings to MySQL charsets. Ultimately we need the MySQL charset for the conversion. So... I believe what needs to be checked in that second isset() is $charsets[$lang_charsets[$language]]. We should probably keep the capitalization fixes also, in case folks edited Settings.php. I think they're in the wrong place, though... As-is, the capitalization fixes don't end up in $upcontext['charset_detected'] at all, they're within an isset()...
Test.
If you like, I can take a stab at this. Should be simple. Only complicated part is testing, & setting up the 2.0 environments properly.
If you want to run the SMF upgrader in Ukrainian, you will need to install the 2.1 Ukrainian language pack prior to the upgrade, so the upgrader has the translations for 2.1. Do this at the same time you unpack the upgrader files, before execution. This will prevent the upgrader error about outdated Ukrainian language files.
Activity
sbulen commentedon Oct 20, 2026
Just to confirm: All your tables are latin1_swedish_ci?
Do you have an entry in Settings.php for $db_character_set? If so, what's the value?
Do you have an entry in the smf_settings table for global_character_set? If so, what's the value?
sbulen commentedon Oct 20, 2026
One last question: Did you copy the 2.1 Ukrainian language package over before the upgrade?
(Just gathering info at the moment...)
bSerge21 commentedon Oct 21, 2026
jdarwood007 commentedon Oct 24, 2026
I think the step 4 is the issue here. The code says
So it looks for languages we have, including
$language,which is from Settings.php, but then also checks$txt['lang_character_set'].It falls backto the ISO-8859-1 when it fails.
sbulen commentedon Oct 25, 2026
I think the issue is even more fundamental than that...
Do we really know the DB charset by looking at the language?
I think the problem they were trying to solve was that, back in the day, different charsets were stuffed into latin1 - it was treated as binary. Querying the DB you'd see latin1. But to do the conversion properly, you'd need to know what charset was stuffed into that latin1.
Note it should never use $txt['lang_character_set']... To properly use a non-English language during the upgrade, you'd need to install the 2.1 language pack for that language. In 2.1, that will always point to 'UTF-8', which is not helpful.
jdarwood007 commentedon Nov 12, 2026
I sent up the typo fix. Need more information to figure out the other issue. Although the typo may correct it.
sbulen commentedon Nov 13, 2026
I think we need to do 3 things here...
SMF/other/upgrade.php
Line 3183 in a1faa0c
It shouldn't be using charset_detected, because it's not set yet. It shouldn't be using lang_character_set either, because in 2.1 that will always be 'UTF-8', and will never tell us where we're moving FROM.
That logic is trying to make sure that you can do lookups in both $charsets and $lang_charsets based on the forum's primary language from Settings.php, $language.
It's a two-level lookup... $lang_charsets translate from $language to encodings... $charsets translates from encodings to MySQL charsets. Ultimately we need the MySQL charset for the conversion. So... I believe what needs to be checked in that second isset() is $charsets[$lang_charsets[$language]]. We should probably keep the capitalization fixes also, in case folks edited Settings.php. I think they're in the wrong place, though... As-is, the capitalization fixes don't end up in $upcontext['charset_detected'] at all, they're within an isset()...
If you like, I can take a stab at this. Should be simple. Only complicated part is testing, & setting up the 2.0 environments properly.
jdarwood007 commentedon Nov 14, 2026
I think your welcome to tackle this.
jdarwood007 commentedon Nov 14, 2026
I will move the rest of this to a future .10 release.
sbulen commentedon Nov 15, 2026
PR #9895 submitted.
@bSerge21 :
My testing, without #9895:
My testing, with #9895: