rename skip_callback->suspend_callbacks
refs CNVS-9522 in rails3 ActiveRecord::Base.skip_callback is a real thing that doesn't do what this does. because of load order, ours happens, but it would be nice to leave the other available. to simplify the switch, both suspend_callback and suspend_callbacks are kept as renames, but suspend_callback should not be used, preferring suspend_callbacks. suspend_callback will go away in the near future. skip_callback is temporarily added back in as an alias to suspend_callback to allow time for fixing a plugin that uses skip_callback. it will be removed as soon as that plugin is updated. Change-Id: Iaefd16dde3b6ce575780cb8f721dc826258eef4e Reviewed-on: https://gerrit.instructure.com/29808 Tested-by: Jenkins <jenkins@instructure.com> Reviewed-by: Nick Cloward <ncloward@instructure.com> Product-Review: Jacob Fugal <jacob@instructure.com> QA-Review: Jacob Fugal <jacob@instructure.com>
This commit is contained in:
parent
d97300cd57
commit
a2c3dc44fc
|
@ -611,7 +611,7 @@ class Conversation < ActiveRecord::Base
|
|||
def merge_into(other)
|
||||
transaction do
|
||||
new_participants = other.conversation_participants.index_by(&:user_id)
|
||||
ConversationParticipant.skip_callback(:destroy_conversation_message_participants) do
|
||||
ConversationParticipant.suspend_callbacks(:destroy_conversation_message_participants) do
|
||||
conversation_participants(true).each do |cp|
|
||||
if new_cp = new_participants[cp.user_id]
|
||||
new_cp.update_attribute(:workflow_state, cp.workflow_state) if cp.unread? || new_cp.archived?
|
||||
|
|
|
@ -2840,7 +2840,7 @@ class Course < ActiveRecord::Base
|
|||
# sections of the course, so that a section limited teacher can grade them.
|
||||
def sync_enrollments(fake_student)
|
||||
self.default_section unless course_sections.active.any?
|
||||
Enrollment.skip_callback(:update_cached_due_dates) do
|
||||
Enrollment.suspend_callbacks(:update_cached_due_dates) do
|
||||
self.course_sections.active.each do |section|
|
||||
# enroll fake_student will only create the enrollment if it doesn't already exist
|
||||
self.enroll_user(fake_student, 'StudentViewEnrollment',
|
||||
|
|
|
@ -884,7 +884,7 @@ class User < ActiveRecord::Base
|
|||
# avoid extraneous callbacks when enrolled in multiple sections
|
||||
def delete_enrollments
|
||||
courses_to_update = self.enrollments.active.select(:course_id).uniq.map(&:course_id)
|
||||
Enrollment.skip_callback(:update_cached_due_dates) do
|
||||
Enrollment.suspend_callbacks(:update_cached_due_dates) do
|
||||
self.enrollments.each { |e| e.destroy }
|
||||
end
|
||||
courses_to_update.each do |course|
|
||||
|
|
|
@ -33,7 +33,7 @@ class EnsureSubmissionsForDiscussions < ActiveRecord::Migration
|
|||
touched_user_ids = [].to_set
|
||||
|
||||
# don't touch the user on each submission, we'll do them in bulk later
|
||||
Submission.skip_callbacks(:touch_user) do
|
||||
Submission.suspend_callbacks(:touch_user) do
|
||||
entries.each do |entry|
|
||||
# streamlined entry.discussiont_topic.ensure_submission(entry.user)
|
||||
assignment = Assignment.find_by_sql(<<-SQL).first
|
||||
|
|
|
@ -41,7 +41,7 @@ class EnrollmentsFromUserList
|
|||
|
||||
list.addresses.slice!(0,@limit) if @limit
|
||||
@course.transaction do
|
||||
Enrollment.skip_callback(:update_cached_due_dates) do
|
||||
Enrollment.suspend_callbacks(:update_cached_due_dates) do
|
||||
list.users.each { |user| enroll_user(user) }
|
||||
end
|
||||
if !@enrollments.empty?
|
||||
|
|
|
@ -24,7 +24,7 @@ module SIS
|
|||
def process
|
||||
start = Time.now
|
||||
importer = Work.new(@batch_id, @root_account, @logger)
|
||||
Account.skip_callback(:update_account_associations_if_changed) do
|
||||
Account.suspend_callbacks(:update_account_associations_if_changed) do
|
||||
Account.process_as_sis(@sis_options) do
|
||||
yield importer
|
||||
end
|
||||
|
|
|
@ -27,7 +27,7 @@ module SIS
|
|||
course_ids_to_update_associations = [].to_set
|
||||
|
||||
importer = Work.new(@batch_id, @root_account, @logger, courses_to_update_sis_batch_id, course_ids_to_update_associations, messages)
|
||||
Course.skip_callback(:update_enrollments_later) do
|
||||
Course.suspend_callbacks(:update_enrollments_later) do
|
||||
Course.process_as_sis(@sis_options) do
|
||||
Course.skip_updating_account_associations do
|
||||
yield importer
|
||||
|
|
|
@ -25,7 +25,7 @@ module SIS
|
|||
def process(messages, updates_every)
|
||||
start = Time.now
|
||||
i = Work.new(@batch_id, @root_account, @logger, updates_every, messages)
|
||||
Enrollment.skip_callbacks(:belongs_to_touch_after_save_or_destroy_for_course, :update_cached_due_dates) do
|
||||
Enrollment.suspend_callbacks(:belongs_to_touch_after_save_or_destroy_for_course, :update_cached_due_dates) do
|
||||
User.skip_updating_account_associations do
|
||||
Enrollment.process_as_sis(@sis_options) do
|
||||
yield i
|
||||
|
|
|
@ -22,7 +22,7 @@ module SIS
|
|||
def process
|
||||
start = Time.now
|
||||
importer = Work.new(@batch_id, @root_account, @logger)
|
||||
Course.skip_callback(:update_enrollments_later) do
|
||||
Course.suspend_callbacks(:update_enrollments_later) do
|
||||
Course.process_as_sis(@sis_options) do
|
||||
CourseSection.process_as_sis(@sis_options) do
|
||||
Course.skip_updating_account_associations do
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
# might not work with Rails 3 (which has built in support for this type
|
||||
# of thing), but this way definitely will
|
||||
class ActiveRecord::Base
|
||||
def self.skip_callback(callback, &block)
|
||||
def self.suspend_callback(callback, &block)
|
||||
method = instance_method(callback)
|
||||
begin
|
||||
remove_method(callback)
|
||||
|
@ -43,11 +43,15 @@ class ActiveRecord::Base
|
|||
end
|
||||
end
|
||||
|
||||
def self.skip_callbacks(*callbacks, &block)
|
||||
def self.suspend_callbacks(*callbacks, &block)
|
||||
return block.call if callbacks.size == 0
|
||||
skip_callback(callbacks[0]) { skip_callbacks(*callbacks[1..-1], &block) }
|
||||
suspend_callback(callbacks[0]) { suspend_callbacks(*callbacks[1..-1], &block) }
|
||||
end
|
||||
|
||||
# temporary
|
||||
def self.skip_callback(callback, &block)
|
||||
suspend_callback(callback, &block)
|
||||
end
|
||||
|
||||
if CANVAS_RAILS2
|
||||
def save_without_callbacks
|
||||
|
|
|
@ -123,7 +123,7 @@ module StickySisFields
|
|||
if opts[:add_sis_stickiness] || opts[:clear_sis_stickiness]
|
||||
yield
|
||||
else
|
||||
self.skip_callback(:set_sis_stickiness) do
|
||||
self.suspend_callbacks(:set_sis_stickiness) do
|
||||
yield
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue