Bug 28001 - Fix delete_patrons.pl if no category is passed
Summary: Fix delete_patrons.pl if no category is passed
Status: CLOSED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: Command-line Utilities (show other bugs)
Version: Main
Hardware: All All
: P5 - low major
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 (kidclamp)
Modified: 2021-12-13 21:10 UTC (History)
4 users (show)

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


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 (kidclamp)
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 (kidclamp)
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Nick Clemens (kidclamp) 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 (kidclamp) 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 (kidclamp) 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 (kidclamp) 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