From 23455c3ab0191148139df365dd7f8d889360e3eb 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 --- C4/Items.pm | 1 + 1 file changed, 1 insertion(+) diff --git a/C4/Items.pm b/C4/Items.pm index 3fd872b091..08d49f98fd 100644 --- a/C4/Items.pm +++ b/C4/Items.pm @@ -2691,6 +2691,7 @@ sub ToggleNewStatus { my $item = C4::Items::GetItem( $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.17.1