Bug 33362

Summary: Return claims can be un-resolvable if issue_id is set but no issue is found in issues or old_issues
Product: Koha Reporter: Kyle M Hall (khall) <kyle>
Component: CirculationAssignee: Kyle M Hall (khall) <kyle>
Status: RESOLVED FIXED QA Contact: Testopia <testopia>
Severity: major    
Priority: P5 - low CC: gmcharlt, kyle.m.hall, rcoert, victor
Version: Main   
Hardware: All   
OS: All   
Change sponsored?: --- Patch complexity: ---
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
23.05.00,22.11.07
Circulation function:
Attachments: Bug 33362: Allow return claims to be resolved even if the issue has since been delete from the database
Bug 33362: Allow return claims to be resolved even if the issue has since been delete from the database
Bug 33362: Allow return claims to be resolved even if the issue has since been delete from the database
Bug 33362: Allow return claims to be resolved even if the issue has since been delete from the database

Description Kyle M Hall (khall) 2023-03-29 18:35:16 UTC
The column return_claims.issue_id is not a foreign key. If for any reason the issue is removed ( such as via cleanup_database.pl ), that claim will raise an FKConstraint exception every time an attempt is made to resolve it.

We should either split that column into two with foreign key constrains, or allow the claim to be resolved even if the related issues cannot be found.
Comment 1 Kyle M Hall (khall) 2023-05-11 14:46:08 UTC
Created attachment 151084 [details] [review]
Bug 33362: Allow return claims to be resolved even if the issue has since been delete from the database

Test Plan:
1) Check out an item
2) Claim return on it, moving it to the old_issues table
3) Delete the old_issue via koha-mysql or Use cleanup_database.pl
4) Attempt to resolve the claim
5) Note the error
6) Apply this patch set
7) Restart all the things!
8) Attempt to resolve the claim
9) No errors!
Comment 2 Kyle M Hall (khall) 2023-05-11 14:48:11 UTC
Created attachment 151085 [details] [review]
Bug 33362: Allow return claims to be resolved even if the issue has since been delete from the database

Test Plan:
1) Check out an item
2) Claim return on it, moving it to the old_issues table
3) Delete the old_issue via koha-mysql or Use cleanup_database.pl
4) Attempt to resolve the claim
5) Note the error
6) Apply this patch set
7) Restart all the things!
8) Attempt to resolve the claim
9) No errors!
Comment 3 Sam Lau 2023-05-19 18:29:18 UTC
Created attachment 151492 [details] [review]
Bug 33362: Allow return claims to be resolved even if the issue has since been delete from the database

Test Plan:
1) Check out an item
2) Claim return on it, moving it to the old_issues table
3) Delete the old_issue via koha-mysql or Use cleanup_database.pl
4) Attempt to resolve the claim
5) Note the error
6) Apply this patch set
7) Restart all the things!
8) Attempt to resolve the claim
9) No errors!

Signed-off-by: Sam Lau <samalau@gmail.com>
Comment 4 Victor Grousset/tuxayo 2023-05-23 02:07:26 UTC
Created attachment 151547 [details] [review]
Bug 33362: Allow return claims to be resolved even if the issue has since been delete from the database

Test Plan:
1) Check out an item
2) Claim return on it, moving it to the old_issues table
3) Delete the old_issue via koha-mysql or Use cleanup_database.pl
4) Attempt to resolve the claim
5) Note the error
6) Apply this patch set
7) Restart all the things!
8) Attempt to resolve the claim
9) No errors!

Signed-off-by: Sam Lau <samalau@gmail.com>
Signed-off-by: Victor Grousset/tuxayo <victor@tuxayo.net>
Comment 5 Victor Grousset/tuxayo 2023-05-23 02:08:12 UTC
Works, makes sense, QA script happy, code looks good, passing QA :)
Comment 6 Tomás Cohen Arazi (tcohen) 2023-05-24 14:22:29 UTC
Pushed to master for 23.05.

Nice work everyone, thanks!
Comment 7 Matt Blenkinsop 2023-06-08 17:15:47 UTC
Nice work everyone!

Pushed to stable for 22.11.x