FIX: under certain conditions, raw would change an cooked remain
when editing a post
This commit is contained in:
parent
9e41ee4390
commit
c6e6d00e2b
|
@ -21,21 +21,33 @@ class PostRevisor
|
||||||
@opts = opts
|
@opts = opts
|
||||||
@new_raw = TextCleaner.normalize_whitespaces(new_raw).gsub(/\s+\z/, "")
|
@new_raw = TextCleaner.normalize_whitespaces(new_raw).gsub(/\s+\z/, "")
|
||||||
|
|
||||||
# TODO this is not in a transaction - dangerous!
|
|
||||||
return false unless should_revise?
|
return false unless should_revise?
|
||||||
|
|
||||||
|
@post.acting_user = @editor
|
||||||
|
|
||||||
Post.transaction do
|
Post.transaction do
|
||||||
@post.acting_user = @editor
|
|
||||||
revise_post
|
revise_post
|
||||||
|
|
||||||
|
# TODO these callbacks are being called in a transaction
|
||||||
|
# it is kind of odd, cause the callback is called before_edit
|
||||||
|
# but the post is already edited at this point
|
||||||
|
# trouble is that much of the logic of should I edit? is deeper
|
||||||
|
# down so yanking this in front of the transaction will lead to
|
||||||
|
# false positives. This system needs a review
|
||||||
plugin_callbacks
|
plugin_callbacks
|
||||||
|
|
||||||
update_category_description
|
update_category_description
|
||||||
update_topic_excerpt
|
update_topic_excerpt
|
||||||
post_process_post
|
|
||||||
update_topic_word_counts
|
|
||||||
@post.advance_draft_sequence
|
@post.advance_draft_sequence
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# WARNING: do not pull this into the transaction, it can fire events in
|
||||||
|
# sidekiq before the post is done saving leading to corrupt state
|
||||||
|
post_process_post
|
||||||
|
update_topic_word_counts
|
||||||
|
|
||||||
PostAlerter.new.after_save_post(@post)
|
PostAlerter.new.after_save_post(@post)
|
||||||
|
|
||||||
@post.publish_change_to_clients! :revised
|
@post.publish_change_to_clients! :revised
|
||||||
BadgeGranter.queue_badge_grant(Badge::Trigger::PostRevision, post: @post)
|
BadgeGranter.queue_badge_grant(Badge::Trigger::PostRevision, post: @post)
|
||||||
|
|
||||||
|
@ -73,13 +85,11 @@ class PostRevisor
|
||||||
end
|
end
|
||||||
|
|
||||||
def revise_and_create_new_version
|
def revise_and_create_new_version
|
||||||
Post.transaction do
|
@post.version += 1
|
||||||
@post.version += 1
|
@post.last_version_at = get_revised_at
|
||||||
@post.last_version_at = get_revised_at
|
update_post
|
||||||
update_post
|
EditRateLimiter.new(@editor).performed! unless @opts[:bypass_rate_limiter] == true
|
||||||
EditRateLimiter.new(@editor).performed! unless @opts[:bypass_rate_limiter] == true
|
bump_topic unless @opts[:bypass_bump]
|
||||||
bump_topic unless @opts[:bypass_bump]
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def bump_topic
|
def bump_topic
|
||||||
|
|
Loading…
Reference in New Issue