Skip to content

Commit 95643f5

Browse files
authored
FIX: silent option not working for bulk category moves via PostRevisor (#36626)
The `silent` option for bulk category changes was not being respected when `create_revision_on_bulk_topic_moves` was enabled. This caused users watching the destination category to receive notifications even when the "Perform this action silently" checkbox was checked. The bug was introduced in commit 7a099eb which added `silent: @silent` to the `track_topic_field(:category_id)` block. However, since blocks capture `self` at definition time (the class, not the instance), `@silent` was always nil in that context. The fix passes the `silent` value through the `TopicChanges` object which is already available to the block as `tc`. Also extends test coverage to verify both topic watchers and category watchers are properly silenced in both code paths. Ref - meta/t/390993
1 parent 3997ce5 commit 95643f5

File tree

2 files changed

+295
-337
lines changed

2 files changed

+295
-337
lines changed

lib/post_revisor.rb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,14 @@ class PostRevisor
1010
# changed a value or not. This is needed for things like custom fields.
1111
class TopicChanges
1212
attr_reader :topic, :user
13+
attr_accessor :silent
1314

1415
def initialize(topic, user)
1516
@topic = topic
1617
@user = user
1718
@changed = {}
1819
@errored = false
20+
@silent = false
1921
end
2022

2123
def errored?
@@ -96,7 +98,7 @@ def self.track_and_revise(topic_changes, field, attribute)
9698
end
9799

98100
tc.record_change("category_id", current_category&.id, new_category&.id)
99-
tc.check_result(tc.topic.change_category_to_id(new_category_id, silent: @silent))
101+
tc.check_result(tc.topic.change_category_to_id(new_category_id, silent: tc.silent))
100102
create_small_action_for_category_change(
101103
topic: tc.topic,
102104
user: tc.user,
@@ -283,6 +285,7 @@ def revise!(editor, fields, opts = {})
283285

284286
@silent = false
285287
@silent = @opts[:silent] if @opts.has_key?(:silent)
288+
@topic_changes.silent = @silent
286289

287290
@post.incoming_email&.update(imap_sync: true) if @post.incoming_email&.imap_uid
288291

0 commit comments

Comments
 (0)