More encoded slug fixes (PR #8191)

A bunch of extra places to consider when dealing with encoded slugs.

GitHub

You’ve signed the CLA, xfalcox. Thank you! This pull request is ready for review.

Could you use this.siteSettings? Should be available in the Category model.

id > 4? why that specific hard coded value?

I want to skip the built-in categories (staff, uncategorized, Lounge, Site Feedback are 1,2,3,4). Is there a way to query those equivalent to User.human? or Group.automatic? ?

I could use Category.list()[0].siteSettings.slug_generation_method to access it but IMO is ugly as hell, and looks like almost every model is using the global:

This pull request has been mentioned on Discourse Meta. There might be relevant details there:

https://meta.discourse.org/t/404-on-various-categories/130892/6

This pull request has been mentioned on Discourse Meta. There might be relevant details there:

https://meta.discourse.org/t/404-on-various-categories/130892/6

Ugh, good point. We should make it a service eventually.

It doesn’t look like there is. I think at least we should use a constant here. Perhaps add a seeded? method to Category that is true if the id is in that range. Later we could make that an actual column.

I agree. It would be a good idea to add seeded? and check if the id equals one of the following site settings.

https://github.com/discourse/discourse/blob/48c123849228cc8a392e989558fe89734cd02656/config/site_settings.yml#L1823-L1835

Damn this is so much better! Thanks for the suggestion @gschlager !

3 Likes