Bug 41967: Ensure --cards argument accepts an integer in cleanup_database.pl

Test plan (for --cards arguments) :

1. Initial Setup:
    a) Go to Tools > Patron card creator > New > Card batch
    b) Create two different batches (Batch 1 and Batch 2) using the 'Add by borrowernumber(s):' option.
        If using **KTD** you can use the following borrowernumbers for both batches:
            15
            29
            47
        else you will need to create your own patrons and enter their borrowernumber.
    c) In your terminal, set the timestamps manually:
        --OPTION A (KTD users):
            ktd --shell
            koha-mysql kohadev

        --OPTION B:
            Access your database

        Then:
            UPDATE creator_batches SET timestamp = DATE_SUB(NOW(), INTERVAL 30 DAY) WHERE batch_id = '1';
            UPDATE creator_batches SET timestamp = DATE_SUB(NOW(), INTERVAL 5 DAY) WHERE batch_id = '2';

    Note: your batch_id may differ.

2. Before Applying the Patch:
    a) Run the following cleanup script:
        ./misc/cronjobs/cleanup_database.pl --cards 15 --confirm --verbose
    b) Error in console output
    c) Nothing is deleted even though one batch was older than 15 days
        SELECT * FROM creator_batches;

3. Apply The Patch

4. After Applying The Patch:
    a) Redo step 1 (Initial Setup).
    b) Run again the following cleanup script:
        ./misc/cronjobs/cleanup_database.pl --cards 15 --confirm --verbose
    c) Check that the console output says: "Purging ... more than 15 days ago"
    d) Batch 1 is deleted, but Batch 2 (5 days old) is STILL PRESENT. Success!
        SELECT * FROM creator_batches;

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Thomas Klausner <domm@plix.at>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
(cherry picked from commit 0c2ef0e6b4)
Signed-off-by: Jacob O'Mara <Jacob.omara@openfifth.co.uk>
Signed-off-by: Wainui Witika-Park <wainuiwitikapark@catalyst.net.nz>
This commit is contained in:
Ayoub Glizi-Vicioso 2026-03-05 14:22:55 -05:00 committed by Wainui Witika-Park
parent 6261325bbd
commit 129cc9054b
No known key found for this signature in database
GPG Key ID: 2D0A6AB5DAF1B78D
1 changed files with 3 additions and 3 deletions

View File

@ -222,7 +222,7 @@ GetOptions(
'pseudo-transactions-from:s' => \$pPseudoTransactionsFrom,
'pseudo-transactions-to:s' => \$pPseudoTransactionsTo,
'labels:i' => \$labels,
'cards' => \$cards,
'cards:i' => \$cards,
'return-claims' => \$return_claims,
'jobs-type:s' => \@jobs_types,
'jobs-days:i' => \$jobs_days,
@ -771,11 +771,11 @@ if ($labels) {
if ($cards) {
print "Purging card creator batches last added to more than $cards days ago.\n" if $verbose;
my $count = PurgeCreatorBatches( $labels, 'patroncards', $confirm );
my $count = PurgeCreatorBatches( $cards, 'patroncards', $confirm );
if ($verbose) {
say $confirm
? sprintf "Done with purging %d card creator batches last added to more than %d days ago.\n", $count,
$labels
$cards
: sprintf "%d card creator batches would have been purged.", $count;
}
}