FIX: redirect to parent tag when synonym page visited (#31688)

When a synonym page is visited, the user should be redirected to the
parent tag.
This commit is contained in:
Krzysztof Kotlarek
2025-03-10 09:45:38 +11:00
committed by GitHub
parent 2237a0b0d5
commit 7da4fe82b6
2 changed files with 15 additions and 2 deletions

View File

@ -142,6 +142,18 @@ class TagsController < ::ApplicationController
Discourse.filters.each do |filter|
define_method("show_#{filter}") do
parent_tag_name =
Tag
.where_name(params[:tag_id])
.where.not(target_tag_id: nil)
.joins("JOIN tags parent_tags ON parent_tags.id = tags.target_tag_id")
.pick("parent_tags.name")
if parent_tag_name
params[:tag_id] = parent_tag_name
return redirect_to url_for(params.to_unsafe_hash)
end
@tag_id = params[:tag_id].force_encoding("UTF-8")
@additional_tags =
params[:additional_tag_ids].to_s.split("/").map { |t| t.force_encoding("UTF-8") }