diff --git a/lib/post_destroyer.rb b/lib/post_destroyer.rb index 49fd91b887d..22821fa5eac 100644 --- a/lib/post_destroyer.rb +++ b/lib/post_destroyer.rb @@ -13,6 +13,8 @@ class PostDestroyer end def self.destroy_stubs + context = I18n.t('remove_posts_deleted_by_author') + # exclude deleted topics and posts that are actively flagged Post.where(deleted_at: nil, user_deleted: true) .where("NOT EXISTS ( @@ -28,8 +30,9 @@ class PostDestroyer pa.deleted_at IS NULL AND pa.post_action_type_id IN (?) )", PostActionType.notify_flag_type_ids) - .each do |post| - PostDestroyer.new(Discourse.system_user, post, {context: I18n.t('remove_posts_deleted_by_author')}).destroy + .find_each do |post| + + PostDestroyer.new(Discourse.system_user, post, context: context).destroy end end diff --git a/spec/components/post_destroyer_spec.rb b/spec/components/post_destroyer_spec.rb index 58781bd2f14..37b35ab2853 100644 --- a/spec/components/post_destroyer_spec.rb +++ b/spec/components/post_destroyer_spec.rb @@ -467,4 +467,3 @@ describe PostDestroyer do end end -