Skip to content

[2.1.8]: upgrade.php: typo 'ukranian' in $lang_charsets, Ukrainian 2.0 forums converted as ISO-8859-1 instead of windows-1251 #9786

Open

Description

@bSerge21

Basic Information

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

  1. 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.
  2. Run upgrade.php from the 2.1.8 "Large upgrade" package (web or CLI).
  3. The "Convert to UTF-8" step runs without asking for the source charset.
  4. Check any Cyrillic subject/post: it is garbled (e.g. "dzðêîâ³ â³éíè").

Expected result

No response

Actual result

No response

Version/Git revision

2.1.8

Database Engine

All

Database Version

No response

PHP Version

No response

Logs

Additional Information

No response

Activity

  1. sbulen commented on Oct 20, 2026

    @sbulen
    Contributor

    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?

  2. sbulen commented on Oct 20, 2026

    @sbulen
    Contributor

    One last question: Did you copy the 2.1 Ukrainian language package over before the upgrade?

    (Just gathering info at the moment...)

  3. bSerge21 commented on Oct 21, 2026

    @bSerge21
    Author
  4. jdarwood007 commented on Oct 24, 2026

    @jdarwood007
    Member

    I think the step 4 is the issue here. The code says

    		// Default to ISO-8859-1 unless we detected another supported charset
    		$upcontext['charset_detected'] = (isset($lang_charsets[$language]) && isset($charsets[strtr(strtolower($upcontext['charset_detected'] ?? $txt['lang_character_set']), array('utf' => 'UTF', 'iso' => 'ISO'))])) ? $lang_charsets[$language] : 'ISO-8859-1';
    

    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.

  5. sbulen commented on Oct 25, 2026

    @sbulen
    Contributor

    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.

  6. added this to the 2.1.9 milestone on Nov 12, 2026
  7. jdarwood007 commented on Nov 12, 2026

    @jdarwood007
    Member

    I sent up the typo fix. Need more information to figure out the other issue. Although the typo may correct it.

  8. sbulen commented on Nov 13, 2026

    @sbulen
    Contributor

    I think we need to do 3 things here...

    1. Looking at the history of recent changes on that logic, we missed it in [2.1.4]: upgrade from SMF 2.0.18 fails if the forum is in Slovenian language and UTF-8 #8125 when @gregorklaric pointed out the typo in 'croation'... We should fix that while we're here...
    2. This line is still broken, IMO:
      $upcontext['charset_detected'] = (isset($lang_charsets[$language]) && isset($charsets[strtr(strtolower($upcontext['charset_detected'] ?? $txt['lang_character_set']), array('utf' => 'UTF', 'iso' => 'ISO'))])) ? $lang_charsets[$language] : 'ISO-8859-1';

    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()...

    1. 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.

  9. jdarwood007 commented on Nov 14, 2026

    @jdarwood007
    Member

    I think your welcome to tackle this.

  10. modified the milestones: 2.1.9, 2.1.10 on Nov 14, 2026
  11. jdarwood007 commented on Nov 14, 2026

    @jdarwood007
    Member

    I will move the rest of this to a future .10 release.

  12. sbulen commented on Nov 15, 2026

    @sbulen
    Contributor

    PR #9895 submitted.

    @bSerge21 :

    • The two PRs that I think will address your issue are [2.1] Fix upgrader charset_detected lookup #9895 and [2.1] Misspelled Ukrainian #9878 . If you can test, that would help.
    • 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.

    My testing, without #9895:

    ukr_before_lookup_fix

    My testing, with #9895:

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions