From ffdb2d0010169f43c6497399fd4a8f226fb5d4e8 Mon Sep 17 00:00:00 2001 From: Kirill Solomko Date: Fri, 14 Jun 2019 17:47:26 +0200 Subject: [PATCH] TT#60502 fix PATCH removal by value when multiple elements are removed * elements must be removed reversed so last index is removed first, otherwise the list "for removal" becomes out of sync with the "current elements" causing wrong values to be removed, or an out of bounds index array error Change-Id: I9ab9bce8205169bc7841c51f37743ab17946cc11 --- lib/NGCP/Panel/Role/API.pm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/NGCP/Panel/Role/API.pm b/lib/NGCP/Panel/Role/API.pm index 118f9b01ae..52d53f7051 100644 --- a/lib/NGCP/Panel/Role/API.pm +++ b/lib/NGCP/Panel/Role/API.pm @@ -867,14 +867,14 @@ sub process_patch_description { if ($found_count == $remove_index) { #if we want to use patch info to try to make clear changes, we shouldn't use replace #from the other pov, if we requested 10000 removals, we will have 10000 new op entries - push @$patch_diff, {"op" => "remove", "path" => $op->{path}.'/'.$i }; + unshift @$patch_diff, {"op" => "remove", "path" => $op->{path}.'/'.$i }; $removal_done = 1; last; } else { $found_count++; } } else { - push @$patch_diff, {"op" => "remove", "path" => $op->{path}.'/'.$i }; + unshift @$patch_diff, {"op" => "remove", "path" => $op->{path}.'/'.$i }; } } }