Skip to content

Rails 5 deprecation: Passing an argument to force an association to reload is now deprecated

Jasper Maes requested to merge jlemaes/gitlab-ce:force-reload-arguments-1 into master

What does this MR do?

Fixes DEPRECATION WARNING: Passing an argument to force an association to reload is now deprecated and will be removed in Rails 5.1. Please call `reload` on the result collection proxy instead. (called from save_commits at /builds/gitlab-org/gitlab-ce/app/models/merge_request_diff.rb:316)

Just using merge_request_diff_commits.reload doesn't work. When using merge_request_diff_commits(true) rails uses an uncached connection, see https://github.com/rails/rails/blob/8688fc4e404e687fe66c7ac214c33ea82710f57e/activerecord/lib/active_record/associations/collection_association.rb#L37. So we can remove the deprecation by explicitly using ActiveRecord::Base.uncached { merge_request_diff_commits.reload }

What are the relevant issue numbers?

Does this MR meet the acceptance criteria?

Merge request reports