From c16f01e0e062425f86244627fdc48f76e6f564dd Mon Sep 17 00:00:00 2001 From: Fridolin Somers Date: Fri, 7 Dec 2018 16:05:52 +0100 Subject: [PATCH] Bug 21975: Avoid unnecessary substitutions in automatic item modification by age Automatic item modification by age cronjob is based on rules with conditions and substitutions. When substitution value is equal to actual item value, the code should not call C4::Items::ModItem. It adds unnecessary action log and entry in zebraqueue. With a rule than can impact all catalogue you can explode your database with action logs. Test plan : 1) Run prove t/db_dependent/Items/AutomaticItemModificationByAge.t 2) Define a item modification by age with no condition 3) Run several times misc/cronjobs/automatic_item_modification_by_age.pl 4) Check it creates only one entry in action_logs and zebraqueue Signed-off-by: Martin Renvoize Signed-off-by: Katrin Fischer --- C4/Items.pm | 1 + 1 file changed, 1 insertion(+) diff --git a/C4/Items.pm b/C4/Items.pm index 66ce7af00e..dcbf4aef94 100644 --- a/C4/Items.pm +++ b/C4/Items.pm @@ -2643,6 +2643,7 @@ sub ToggleNewStatus { my $itemnumber = $values->{itemnumber}; for my $substitution ( @$substitutions ) { next unless $substitution->{field}; + next if ( $item->{ $substitution->{item_field} } eq $substitution->{value} ); C4::Items::ModItem( { $substitution->{item_field} => $substitution->{value} }, $biblionumber, $itemnumber ) unless $report_only; push @{ $report->{$itemnumber} }, $substitution; -- 2.11.0