From 3e0d6100314c3c6536f6145110796ed91ceb2c62 Mon Sep 17 00:00:00 2001 From: Marcel de Rooy Date: Wed, 22 Sep 2021 14:06:07 +0000 Subject: [PATCH] Bug 29078: Resolve division by zero in touch_all scripts Illegal division by zero at misc/maintenance/touch_all_biblios.pl line 102. Trivial fix. Funny that the percentage is not even shown without verbose flag ;) Test plan: Run misc/maintenance/touch_all_biblios.pl -where 'biblionumber<0' You should now see: Good: 0, Bad: 0 (of 0) in 0 seconds Signed-off-by: Marcel de Rooy Signed-off-by: Martin Renvoize Signed-off-by: Jonathan Druart Signed-off-by: Kyle M Hall --- misc/maintenance/touch_all_biblios.pl | 2 +- misc/maintenance/touch_all_items.pl | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/misc/maintenance/touch_all_biblios.pl b/misc/maintenance/touch_all_biblios.pl index 8d65f21eed..11425977bb 100755 --- a/misc/maintenance/touch_all_biblios.pl +++ b/misc/maintenance/touch_all_biblios.pl @@ -101,7 +101,7 @@ close($fh); # Benchmarking my $endtime = time(); my $time = $endtime-$startime; -my $accuracy = ($goodcount / $totalcount) * 100; # this is a percentage +my $accuracy = $totalcount ? ($goodcount / $totalcount) * 100 : 0; # this is a percentage my $averagetime = 0; $averagetime = $time / $totalcount if $totalcount; print "Good: $goodcount, Bad: $badcount (of $totalcount) in $time seconds\n"; diff --git a/misc/maintenance/touch_all_items.pl b/misc/maintenance/touch_all_items.pl index dbf1609221..7bdc423e14 100755 --- a/misc/maintenance/touch_all_items.pl +++ b/misc/maintenance/touch_all_items.pl @@ -110,7 +110,7 @@ close($fh); # Benchmarking my $endtime = time(); my $time = $endtime-$startime; -my $accuracy = ($goodcount / $totalcount) * 100; # this is a percentage +my $accuracy = $totalcount ? ($goodcount / $totalcount) * 100 : 0; # this is a percentage my $averagetime = 0; $averagetime = $time / $totalcount if $totalcount; print "Good: $goodcount, Bad: $badcount (of $totalcount) in $time seconds\n"; -- 2.39.5