From d306da9f8dce5c5266629e5fe376af2804ce3c3b Mon Sep 17 00:00:00 2001 From: David Gustafsson Date: Fri, 1 Oct 2021 15:42:24 +0200 Subject: [PATCH] Bug 14957: Fix regression, rules must be refetched on add/edit/deletion Signed-off-by: Martin Renvoize Signed-off-by: Jonathan Druart --- admin/marc-overlay-rules.pl | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/admin/marc-overlay-rules.pl b/admin/marc-overlay-rules.pl index 07df4a2444..377ed1b34f 100755 --- a/admin/marc-overlay-rules.pl +++ b/admin/marc-overlay-rules.pl @@ -61,8 +61,10 @@ my ($template, $loggedinuser, $cookie) = get_template_and_user( } ); -# TODO: order? -my $rules = Koha::MarcOverlayRules->search->unblessed; +my $get_rules = sub { + return Koha::MarcOverlayRules->search( undef, { order_by => { -asc => 'id' } } )->unblessed; +}; +my $rules = $get_rules->(); if ($op eq 'remove' || $op eq 'doremove') { my @remove_ids = $input->multi_param('batchremove'); @@ -78,6 +80,8 @@ if ($op eq 'remove' || $op eq 'doremove') { my @remove_ids = $input->multi_param('batchremove'); push @remove_ids, scalar $input->param('id') if $input->param('id'); Koha::MarcOverlayRules->search({ id => { in => \@remove_ids } })->delete(); + # Update $rules after deletion + $rules = $get_rules->(); } } elsif ($op eq 'edit') { @@ -123,6 +127,8 @@ elsif ($op eq 'doedit' || $op eq 'add') { $rule->set($rule_data); $rule->store(); } + # Update $rules after edit/add + $rules = $get_rules->(); } } -- 2.39.5