Commit 32e45d8c authored by Kamil Trzciński's avatar Kamil Trzciński

EE: Forbid the use of `#reload` and prefer `#reset`

The `#reload` makes to load all objects into memory,
and the main purpose of `#reload` is to drop the association cache.

The `#reset` seems to solve exactly that case.
parent 829d5cd5
......@@ -77,9 +77,9 @@ module VisibleApprovable
end
def reset_approval_cache!
approvals.reload
approved_by_users.reload
approval_rules.reload
approvals.reset
approved_by_users.reset
approval_rules.reset
clear_memoization(:approvers_left)
clear_memoization(:all_approvers_including_groups)
......
......@@ -25,7 +25,7 @@ class ProjectFeatureUsage < ApplicationRecord
touch(self.class.jira_dvcs_integration_field(cloud: cloud))
end
rescue ActiveRecord::RecordNotUnique
reload
reset
retry
end
end
......@@ -9,7 +9,7 @@ module ApprovalRules
filter_eligible_groups!
if rule.update(params)
rule.reload
rule.reset
success
else
error(rule.errors.messages)
......
......@@ -16,8 +16,8 @@ module CleanupApprovers
# If the target already has `approvers` and/or `approver_groups` loaded then we need to
# force a reload in order to not return stale information after the destroys above
if reload
target.approvers.reload
target.approver_groups.reload
target.approvers.reset
target.approver_groups.reset
end
target
......
......@@ -18,7 +18,7 @@ module EE
return unless can?(current_user, :update_epic, epic_issue.epic.group)
epic_issue.update(issue_id: new_entity.id)
original_entity.reload
original_entity.reset
end
end
end
......
......@@ -18,7 +18,7 @@ module Epics
if have_epic_dates_changed?(epic)
epic.update_start_and_due_dates
epic.reload
epic.reset
end
epic
......
......@@ -48,7 +48,7 @@ module Gitlab
# No caching of the enabled! If we cache it and an admin disables
# this node, an active Geo::RepositorySyncWorker would keep going for up
# to max run time after the node was disabled.
Gitlab::Geo.current_node.reload.enabled?
Gitlab::Geo.current_node.reset.enabled?
end
def self.geo_database_configured?
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment