mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FIX: Inherit topic auto close when changing topic's category.
This commit is contained in:
@@ -170,7 +170,6 @@ class Topic < ActiveRecord::Base
|
||||
|
||||
before_create do
|
||||
initialize_default_values
|
||||
inherit_auto_close_from_category
|
||||
end
|
||||
|
||||
after_create do
|
||||
@@ -187,6 +186,10 @@ class Topic < ActiveRecord::Base
|
||||
if title_changed?
|
||||
write_attribute :fancy_title, Topic.fancy_title(title)
|
||||
end
|
||||
|
||||
if category_id_changed? || new_record?
|
||||
inherit_auto_close_from_category
|
||||
end
|
||||
end
|
||||
|
||||
after_save do
|
||||
@@ -614,8 +617,7 @@ SQL
|
||||
old_category = category
|
||||
|
||||
if self.category_id != new_category.id
|
||||
self.category_id = new_category.id
|
||||
self.update_column(:category_id, new_category.id)
|
||||
self.update!(category_id: new_category.id)
|
||||
Category.where(id: old_category.id).update_all("topic_count = topic_count - 1") if old_category
|
||||
|
||||
# when a topic changes category we may have to start watching it
|
||||
|
||||
Reference in New Issue
Block a user