DEV: Ensure consistency in PostCreator hook order (#30668)

Previously we would enqueue sidekiq jobs like `PostProcessCooked` **before** triggering the `topic_created` and `post_created` DiscourseEvents. That means that, depending on the speed/availability of Sidekiq, PostProcessCooked might start running on another host before the DiscourseEvents have been executed.

This commit moves the event triggers before enqueue_jobs, so that ordering is guaranteed to be consistent, regardless of Sidekiq performance.
This commit is contained in:
David Taylor 2025-01-09 09:52:13 +00:00 committed by GitHub
parent 138b02448b
commit adb4715109
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -214,11 +214,11 @@ class PostCreator
publish
track_latest_on_category
trigger_after_events unless opts[:skip_events]
enqueue_jobs unless @opts[:skip_jobs]
BadgeGranter.queue_badge_grant(Badge::Trigger::PostRevision, post: @post)
trigger_after_events unless opts[:skip_events]
auto_close
end