mirror of
https://github.com/discourse/discourse.git
synced 2025-05-22 22:43:33 +08:00
FIX: You could update a topic to have a title that's too short if the TextCleaner
removed extra characters. Additionally, updating the title will not return an error message to the client app if the operation fails (rather than failing silently.)
This commit is contained in:
@ -62,14 +62,19 @@ class TopicsController < ApplicationController
|
||||
topic.archetype = "regular" if params[:archetype] == 'regular'
|
||||
end
|
||||
|
||||
success = false
|
||||
Topic.transaction do
|
||||
topic.save
|
||||
topic.change_category(params[:category])
|
||||
success = topic.save
|
||||
topic.change_category(params[:category]) if success
|
||||
end
|
||||
|
||||
# this is used to return the title to the client as it may have been
|
||||
# changed by "TextCleaner"
|
||||
render_serialized(topic, BasicTopicSerializer)
|
||||
if success
|
||||
render_serialized(topic, BasicTopicSerializer)
|
||||
else
|
||||
render_json_error(topic)
|
||||
end
|
||||
end
|
||||
|
||||
def similar_to
|
||||
|
Reference in New Issue
Block a user