From ac35b4a55a6e3dea3c8ffbdf3565fafc9bf03305 Mon Sep 17 00:00:00 2001 From: Fridolin Somers Date: Tue, 30 Jan 2024 15:40:29 +0100 Subject: [PATCH] Bug 35948: cleanup_database.pl should remove not only finished background jobs Bug 31969 changed cleanup_database.pl so it removes only finished background jobs. But old background jobs with other statuses will never be removed. So we should use "enqueued_on" instead of "ended_on" and no filter on status Test plan : 1) Create a background job with for example a batch item modification 2) Simulate ancien job via SQL : update background_jobs set status='failed',enqueued_on=DATE_SUB(NOW(),INTERVAL 10 DAY) where id=X 3) Run misc/cronjobs/cleanup_database.pl --jobs-days 9 --jobs-type all -v --confirm 4) Check the job is removed --- misc/cronjobs/cleanup_database.pl | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/misc/cronjobs/cleanup_database.pl b/misc/cronjobs/cleanup_database.pl index 04cc934b9c..663a1d07cf 100755 --- a/misc/cronjobs/cleanup_database.pl +++ b/misc/cronjobs/cleanup_database.pl @@ -744,12 +744,11 @@ if ($jobs_days) { if $verbose; my $jobs = Koha::BackgroundJobs->search( { - status => 'finished', ( $jobs_types[0] eq 'all' ? () : ( type => \@jobs_types ) ) } )->filter_by_last_update( { - timestamp_column_name => 'ended_on', + timestamp_column_name => 'enqueued_on', days => $jobs_days, } ); -- 2.43.0