Bug 30914

Summary: cleanup_database.pl --transfers --old-reserves --confirm does not work
Product: Koha Reporter: Andreas Jonsson <andreas.jonsson>
Component: Command-line UtilitiesAssignee: Jonathan Druart <jonathan.druart+koha>
Status: RESOLVED FIXED QA Contact: Katrin Fischer <katrin.fischer>
Severity: major    
Priority: P5 - low CC: arthur.suzuki, fridolin.somers, jonathan.druart+koha, lucas, robin, victor
Version: unspecified   
Hardware: All   
OS: All   
Change sponsored?: --- Patch complexity: Trivial patch
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
22.11.00, 22.05.03, 21.11.11, 21.05.18
Bug Depends on: 24153    
Bug Blocks:    
Attachments: Bug 30914: (24153 follow-up) Fix cleanup_database.pl --transfers --old-reserves
Bug 30914: (24153 follow-up) Fix cleanup_database.pl --transfers --old-reserves
Bug 30914: (24153 follow-up) Fix cleanup_database.pl --transfers --old-reserves

Description Andreas Jonsson 2022-06-07 07:22:41 UTC
When the --confirm flag was added for bug 24153 the same mistake was made twice - 'delete if $verbose' instead of 'delete if $confirm': 


if ($pOldReserves) {
    print "Purging old reserves older than $pOldReserves days.\n" if $verbose;
    my $old_reserves = Koha::Old::Holds->filter_by_last_update( { days => $pOldReserves } );
    my $count = $old_reserves->count;
    $old_reserves->delete if $verbose;
    say sprintf "Done with purging %d old reserves.", $count if $verbose;
}

if ($pTransfers) {
    print "Purging arrived item transfers older than $pTransfers days.\n" if $verbose;
    my $transfers = Koha::Item::Transfers->filter_by_last_update(
        {
            timestamp_column_name => 'datearrived',
            days => $pTransfers,
        }
    );
    my $count = $transfers->count;
    $transfers->delete if $verbose;
    say sprintf "Done with purging %d transfers.", $count if $verbose;
}
Comment 1 Jonathan Druart 2022-06-07 12:13:18 UTC
Created attachment 135756 [details] [review]
Bug 30914: (24153 follow-up) Fix cleanup_database.pl --transfers --old-reserves

Silly mistake, 'delete if verbose' must be 'delete if confirm'

Test plan:
Try the cleanup_database.pl script to delete transfers and old issues.
Using --transfers --old-reserves and the --confirm flag the entries must be
removed
Comment 2 Jonathan Druart 2022-06-07 12:13:35 UTC
Oops, sorry about that!
Comment 3 Fridolin Somers 2022-06-08 07:04:57 UTC
Created attachment 135789 [details] [review]
Bug 30914: (24153 follow-up) Fix cleanup_database.pl --transfers --old-reserves

Silly mistake, 'delete if verbose' must be 'delete if confirm'

Test plan:
Try the cleanup_database.pl script to delete transfers and old issues.
Using --transfers --old-reserves and the --confirm flag the entries must be
removed

Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
Comment 4 Katrin Fischer 2022-06-12 11:18:38 UTC
Created attachment 135969 [details] [review]
Bug 30914: (24153 follow-up) Fix cleanup_database.pl --transfers --old-reserves

Silly mistake, 'delete if verbose' must be 'delete if confirm'

Test plan:
Try the cleanup_database.pl script to delete transfers and old issues.
Using --transfers --old-reserves and the --confirm flag the entries must be
removed

Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Comment 5 Tomás Cohen Arazi 2022-06-13 13:38:37 UTC
Pushed to master for 22.11.

Nice work everyone, thanks!
Comment 6 Lucas Gass 2022-07-13 19:28:52 UTC
Backported to 22.05.x for 22.05.03
Comment 7 Arthur Suzuki 2022-08-12 08:13:37 UTC
pushed to 21.11.x for 21.11.11
Comment 8 Victor Grousset/tuxayo 2022-08-17 22:44:59 UTC
Backported: Pushed to 21.05.x branch for 21.05.18

Nothing to document, marking resolved.