Commit fffa08d5 authored by Heinrich Lee Yu's avatar Heinrich Lee Yu

Use deep_dup in bulk update service

We have some array parameters in params so it is safer to use deep_dup
in case these are mutated in some way by the update service
parent 37ec7b18
...@@ -60,7 +60,7 @@ module Issuable ...@@ -60,7 +60,7 @@ module Issuable
update_class.new( update_class.new(
**update_class.constructor_container_arg(issuable.issuing_parent), **update_class.constructor_container_arg(issuable.issuing_parent),
current_user: current_user, current_user: current_user,
params: params.dup params: dup_params
).execute(issuable) ).execute(issuable)
end end
...@@ -82,6 +82,19 @@ module Issuable ...@@ -82,6 +82,19 @@ module Issuable
.includes_for_bulk_update .includes_for_bulk_update
end end
# Duplicates params and its top-level values
# We cannot use deep_dup because ActiveRecord objects will result
# to new records with no id assigned
def dup_params
dup = HashWithIndifferentAccess.new
params.each do |key, value|
dup[key] = value.is_a?(ActiveRecord::Base) ? value : value.dup
end
dup
end
def response_success(message: nil, payload: nil) def response_success(message: nil, payload: nil)
ServiceResponse.success(message: message, payload: payload) ServiceResponse.success(message: message, payload: payload)
end end
......
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