Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

Update the StructuredMeeting#calculate_agenda_item_time_slots to not cause StaleObjectError

Dombi Attilab8932da89d9f
diff --git a/modules/meeting/app/models/structured_meeting.rb b/modules/meeting/app/models/structured_meeting.rb
index 84e03b1a17b..acdaeeaeea6 100644
--- a/modules/meeting/app/models/structured_meeting.rb
+++ b/modules/meeting/app/models/structured_meeting.rb
@@ -41,6 +41,14 @@ class StructuredMeeting < Meeting
top
end
+ # Disable the locking_column in order to avoid causing `StaleObjectError`
+ # TODO: The activerecord-import gem does not respect the ActiveRecord::Base.lock_optimistically
+ # flag, so a direct cleaning of the locking_column is necessary.
+ # Once the gem is updated we can use the ActiveRecord::Base.lock_optimistically = false, instead of
+ # removing the locking_column. See: https://github.com/zdennis/activerecord-import/pull/822
+ original_locking_column = MeetingAgendaItem.locking_column
+ MeetingAgendaItem.locking_column = nil
+
MeetingAgendaItem.import(
changed_items,
on_duplicate_key_update: {
@@ -56,9 +64,13 @@ class StructuredMeeting < Meeting
created_at
updated_at
work_package_id
- item_type]
+ item_type
+ lock_version]
}
)
+
+ # Re-enable the locking_column
+ MeetingAgendaItem.locking_column = original_locking_column
end
end
diff --git a/modules/meeting/spec/models/meeting_acts_as_journalized_spec.rb b/modules/meeting/spec/models/meeting_acts_as_journalized_spec.rb
index c0e5df9e411..8f21e9648eb 100644
--- a/modules/meeting/spec/models/meeting_acts_as_journalized_spec.rb
+++ b/modules/meeting/spec/models/meeting_acts_as_journalized_spec.rb
@@ -280,7 +280,7 @@ RSpec.describe Meeting do
describe '#destroy' do
before do
- meeting.agenda_items << build(:meeting_agenda_item)
+ meeting.agenda_items << create(:meeting_agenda_item)
meeting.save
end