mirror of
https://github.com/discourse/discourse.git
synced 2025-03-03 06:28:41 +08:00

In the past, CategoryFeaturedTopic.feature_topics raised an exception sometimes because it tried to create multiple CategoryFeaturedTopic records for the same topic. This code should not raise any exceptions as long as the list of new topic IDs is unique because all previous records are deleted first, then recreated and everything happens inside a transaction. The previous rescue block was dead code anyway because it tried to catch PG::UniqueViolation instead of ActiveRecord::RecordNotUnique. This commit includes a fix to ensure that the topic IDs are unique.