Bug 28001 - Fix delete_patrons.pl if no category is passed
Summary: Fix delete_patrons.pl if no category is passed
Status: RESOLVED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: Command-line Utilities (show other bugs)
Version: master
Hardware: All All
: P5 - low major (vote)
Assignee: Jonathan Druart
QA Contact: Testopia
URL:
Keywords:
Depends on: 27050
Blocks:
  Show dependency treegraph
 
Reported: 2021-03-19 12:37 UTC by Nick Clemens
Modified: 2021-04-22 13:57 UTC (History)
4 users (show)

See Also:
Change sponsored?: ---
Patch complexity: Small patch
Text to go in the release notes:
Version(s) released in:
21.05.00


Attachments
Bug 28001: (bug 27050 follow-up) Fix delete_patrons if no category passed (2.45 KB, patch)
2021-04-09 09:02 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 28001: (bug 27050 follow-up) Fix delete_patrons if no category passed (2.50 KB, patch)
2021-04-09 15:02 UTC, Owen Leonard
Details | Diff | Splinter Review
Bug 28001: (bug 27050 follow-up) Fix delete_patrons if no category passed (2.50 KB, patch)
2021-04-15 15:44 UTC, Nick Clemens
Details | Diff | Splinter Review
Bug 28001: (QA follow-up) Clarify messages and indicate test mode (2.78 KB, patch)
2021-04-15 15:44 UTC, Nick Clemens
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Nick Clemens 2021-03-19 12:37:13 UTC
You cannot run the script without category, the SQL fails - we should either fix this or note that category is mandatory in the script

root@kohadevbox:koha(master)$ perl misc/cronjobs/delete_patrons.pl --expired_before =1910-01-01
C4::Members::GetBorrowersToExpunge(): DBI Exception: DBD::mysql::st execute failed: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ')  GROUP BY borrowers.borrowernumber
        ) xxx WHERE currentissue IS NULL' at line 12 [for Statement "
        SELECT *
        FROM (
            SELECT borrowers.borrowernumber,
                   MAX(old_issues.timestamp) AS latestissue,
                   MAX(issues.timestamp) AS currentissue
            FROM   borrowers
            JOIN   categories USING (categorycode)
            LEFT JOIN (
                SELECT guarantor_id
                FROM borrower_relationships
                WHERE guarantor_id IS NOT NULL
                    AND guarantor_id <> 0
            ) as tmp ON borrowers.borrowernumber=tmp.guarantor_id
            LEFT JOIN old_issues USING (borrowernumber)
            LEFT JOIN issues USING (borrowernumber) WHERE  category_type <> 'S'
        AND ( borrowers.flags IS NULL OR borrowers.flags = 0 )
        AND tmp.guarantor_id IS NULL
     AND dateexpiry < ?  AND categorycode IN ()  GROUP BY borrowers.borrowernumber
Comment 1 Magnus Enger 2021-03-19 14:02:58 UTC
Is this error triggered if you do a "dry run" (without -c|--confirm)? I have been doing some dry runs on 20.05.08 and I have not seen this error.
Comment 2 Nick Clemens 2021-03-19 14:35:44 UTC
(In reply to Magnus Enger from comment #1)
> Is this error triggered if you do a "dry run" (without -c|--confirm)? I have
> been doing some dry runs on 20.05.08 and I have not seen this error.

I believe caused by 27050 - so not affecting 20.05
Comment 3 Jonathan Druart 2021-04-09 09:02:22 UTC
Created attachment 119363 [details] [review]
Bug 28001: (bug 27050 follow-up) Fix delete_patrons if no category passed

GetBorrowersToExpunge must not crash if called with an empty patron
category list

Test plan:
Call delete_patrons.pl with and without patron categories. The script
must work as expected
Comment 4 Owen Leonard 2021-04-09 15:02:22 UTC
Created attachment 119387 [details] [review]
Bug 28001: (bug 27050 follow-up) Fix delete_patrons if no category passed

GetBorrowersToExpunge must not crash if called with an empty patron
category list

Test plan:
Call delete_patrons.pl with and without patron categories. The script
must work as expected

Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Comment 5 Nick Clemens 2021-04-15 15:44:16 UTC
Created attachment 119650 [details] [review]
Bug 28001: (bug 27050 follow-up) Fix delete_patrons if no category passed

GetBorrowersToExpunge must not crash if called with an empty patron
category list

Test plan:
Call delete_patrons.pl with and without patron categories. The script
must work as expected

Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Comment 6 Nick Clemens 2021-04-15 15:44:20 UTC
Created attachment 119651 [details] [review]
Bug 28001: (QA follow-up) Clarify messages and indicate test mode
Comment 7 Jonathan Druart 2021-04-16 10:29:56 UTC
Pushed to master for 21.05, thanks to everybody involved!
Comment 8 Fridolin Somers 2021-04-22 13:57:03 UTC
Depends on Bug 27050 not in 20.11.x