Why my site still generate encoded slug even if SiteSetting.slug_generation_method = none

Some days before, I set SiteSetting.slug_generation_method to encoded, trying to start a chat channel (but not enable chat plugin at all). I see the url is ugly in Chinese locale, so I SiteSetting.slug_generation_method back to none.

However, the site is still generating slug in new topics (not all, but a few). I have no idea what’s wrong with this. I tried to Topic.update_all(slug: "topic") or Topic.update_all(slug: nil) to refresh slug, but still some topics’ slugs are encoded title.

1 Like

Another problem is that I cannot enter a topic with encoded slug , getting ERR_TOO_MANY_REDIRECTS. This kind of topics with encoded slug are generated after I set SiteSetting.slug_generation_method to none.

The log shows

Started GET "/t/%E6%88%91%E4%B9%9F%E8%83%BD%E6%89%BE%E5%88%B0%E5%B1%9E%E4%BA%8E%E6%88%91%E7%9A%84%E9%98%B3%E5%85%89%E5%A4%A7%E7%94%B7%E5%AD%A9%E5%90%97/112562/39" for 10.182.185.76 at 2022-11-23 19:35:09 +0800
  Rendered text template (Duration: 0.0ms | Allocations: 1)
Processing by TopicsController#show as HTML
  Parameters: {"slug"=>"我也能找到属于我的阳光大男孩吗", "topic_id"=>"112562", "post_number"=>"39"}
Redirected to https://my-domain/t/%E8%BF%98%E6%9C%89%E4%B8%8D%E5%88%B040%E5%A4%A9%EF%BC%8C2022%E5%B9%B4%E5%B0%B1%E7%BB%93%E6%9D%9F%E4%BA%86%EF%BC%8C%E8%AF%B7%E7%94%A8%E4%B8%80%E4%B8%AA%E5%AD%97%E6%88%96%E8%80%85%E8%AF%8D%E8%AF%AD%E6%9D%A5%E8%AF%84%E4%BB%B7%E5%AE%83%E5%90%A7/112489
Completed 301 Moved Permanently in 176ms (ActiveRecord: 0.0ms | Allocations: 19880)

I read the code, maybe slugs_do_not_match return true, as %E6%88%91%E4%B9%9F%E8%83%BD%E6%89%BE%E5%88%B0%E5%B1%9E%E4%BA%8E%E6%88%91%E7%9A%84%E9%98%B3%E5%85%89%E5%A4%A7%E7%94%B7%E5%AD%A9%E5%90%97 != 我也能找到属于我的阳光大男孩吗。And this cause a redirect.

  def slugs_do_not_match
    if SiteSetting.slug_generation_method != "encoded"
      params[:slug] && @topic_view.topic.slug != params[:slug]
    else
      params[:slug] && CGI.unescape(@topic_view.topic.slug) != params[:slug]
    end
  end

So the problem is the same, i.e., why my site generates encoded slug when SiteSetting.slug_generation_method is already none.