discourse/db
Natalie Tay 2c590ea289 FIX: Clean localized tag names (#38488)
Localized tag names were never run through `DiscourseTagging.clean_tag`,
unlike regular tag names. A localized name like `mijn-naam" (123)` would
be stored and rendered as-is, breaking body classes (`tag-mijn-naam"
(123)`) and tag display under topic titles.

This PR adds a `before_validation` callback on `TagLocalization` that
cleans names with `DiscourseTagging.clean_tag`. This covers all three
entry points `TagLocalizationCreator`, `TagLocalizationUpdater`, and
`TagSettingsUpdater` at the model.

Includes a post-migration that cleans existing dirty localization names.
The migration only fetches rows that actually violate, names with
special characters from `TAGS_FILTER_REGEXP`, uppercase when
`force_lowercase_tags` is on, or names exceeding `max_tag_length`. The
actual cleaning still uses `DiscourseTagging.clean_tag` so it respects
site settings. We try to minimize calling application code in
migrations, but this is quite controlled.

Related:
https://meta.discourse.org/t/localized-tags-are-not-slugified/398105
2026-03-17 12:24:12 -04:00
..
fixtures FEAT: add webhooks for calendar events (#38315) 2026-03-17 11:56:42 -04:00
migrate DEV: Remove enable_category_type_setup hidden setting (#38396) 2026-03-17 11:56:46 -04:00
post_migrate FIX: Clean localized tag names (#38488) 2026-03-17 12:24:12 -04:00
api_test_seeds.rb DEV: Apply syntax_tree formatting to db/* 2023-01-09 11:59:41 +00:00