[3.0] Stop the forum offering to delete the language it falls back to - #9394
Merged
jdarwood007 merged 1 commit intoAug 8, 2026
Merged
Conversation
The language editor guards its delete button with
if (Utils::$context['lang_id'] != 'english')
and the comment above it says English cannot be deleted. Language ids have not
looked like that since 2.1 — Lang.php maps 'english' to 'en_US' precisely because
it is the old name — so the comparison never matches anything and the button is
offered for every language, including the one the forum is running on. The check
that actually performs the deletion is spelled the same way, so it goes through.
Deleting en_US is worse than losing a translation: Lang::load() falls back to it
for any string the chosen language is missing, so a forum without it has no
backstop.
Guards on the forum's own default language and on en_US, decided once where
lang_id is settled and read by both the action and the template.
Signed-off-by: albertlast <mathiaspapealbert@hotmail.com>
This was referenced Aug 8, 2026
Closed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
The language editor offers to delete the language the forum is running on, and
goes through with it.
template_modify_language_entries()guards the button with:Language ids have not looked like that since 2.1 —
Sources/Lang.phpcarries'english' => 'en_US'in its map of old names to new ones, which is exactly why.$lang_idcomes from$_GET['lid'], so on any 3.0 install it isen_US,de_DEand so on, and the comparison never matches.Languages::modifyLanguage()spells the check the same way when it acts on the post:
so the button is not merely cosmetic.
Deleting
en_USis worse than losing a translation.Lang::load()falls back toit for any string the chosen language is missing:
A forum without it has no backstop.
The guard now covers the forum's own default language and
en_US, decided oncewhere
$lang_idis settled and read by both the action and the template ratherthan written out twice.
Testing
On a clean install of
release-3.0(a7ac468b1), one language installed,?action=admin;area=languages;sa=editlang;lid=en_US:I have not exercised the positive case — a second language still being
deletable — because installing one needs to reach simplemachines.org and this box
has no outbound access. It follows from the same expression, and
en_USis theonly value the negative case can take on a single-language install.
Found while converting this template's inline
confirm()to the sharedyou_surehandler in #9393.Issues References (Fixes|Related|Closes)
Related to #7933