| Summary: | Deleting patron categories or libraries can leave orphaned rules in the overduerules table | ||
|---|---|---|---|
| Product: | Koha | Reporter: | Lucas Gass (lukeg) <lucas> |
| Component: | Circulation | Assignee: | Lucas Gass (lukeg) <lucas> |
| Status: | Failed QA --- | QA Contact: | Testopia <testopia> |
| Severity: | normal | ||
| Priority: | P5 - low | CC: | andrew, gmcharlt, kyle, roman.dolny |
| Version: | Main | ||
| Hardware: | All | ||
| OS: | All | ||
| GIT URL: | Initiative type: | --- | |
| Sponsorship status: | --- | Comma delimited list of Sponsors: | |
| Crowdfunding goal: | 0 | Patch complexity: | Small patch |
| Documentation contact: | Documentation submission: | ||
| Text to go in the release notes: | Version(s) released in: | ||
| Circulation function: | |||
| Attachments: |
Bug 41246: Add foreign key constraints to overduerules table and cascade on delete
Bug 41246: Add foreign key constraints to overduerules table and cascade on delete Bug 41246: DBIC changes [DO NOT PUSH] |
||
|
Description
Lucas Gass (lukeg)
2025-11-13 14:18:09 UTC
Just notices this is also true of branches. If I make a rule for a specific branch and then deleted the branch, the overduerule remains. Created attachment 189564 [details] [review] Bug 41246: Add foreign key constraints to overduerules table and cascade on delete To test: 0. APPLY PATCH, updatedatabase, restart_all 1. Add or have a patron category. 2. Go to Tools > Overdue notice/status triggers 3. Set some rules for that category. 4. Delete the patron category 5. Now do "select distinct categorycode from overduerules;" 6. All rules should be gone. Created attachment 189565 [details] [review] Bug 41246: Add foreign key constraints to overduerules table and cascade on delete To test: 0. APPLY PATCH, updatedatabase, restart_all 1. Add or have a patron category. 2. Go to Tools > Overdue notice/status triggers 3. Set some rules for that category. 4. Delete the patron category 5. Now do "select distinct categorycode from overduerules;" 6. All rules should be gone. Created attachment 189566 [details] [review] Bug 41246: DBIC changes [DO NOT PUSH] It's worth noting explicitly that these orphaned rules cause the overdues cron to fail and not generate notices for anyone. Can not confirm p. 3, error when saving changes: Error trace CGI::Compile::ROOT::kohadevbox_koha_tools_overduerules_2epl::overduerules_2epl(): DBI Exception: DBD::mysql::st execute failed: Cannot add or update a child row: a foreign key constraint fails (`koha_kohadev`.`overduerules`, CONSTRAINT `overduerules_ibfk_branchcode` FOREIGN KEY (`branchcode`) REFERENCES `branches` (`branchcode`) ON DELETE CASCADE ON UPDATE CASCADE) at /usr/share/perl5/CGI/Emulate/PSGI.pm line 30 at /usr/share/perl5/DBIx/Class/Exception.pm line 77 (In reply to Roman Dolny from comment #6) > Can not confirm p. 3, error when saving changes: > > Error trace > CGI::Compile::ROOT::kohadevbox_koha_tools_overduerules_2epl:: > overduerules_2epl(): DBI Exception: DBD::mysql::st execute failed: Cannot > add or update a child row: a foreign key constraint fails > (`koha_kohadev`.`overduerules`, CONSTRAINT `overduerules_ibfk_branchcode` > FOREIGN KEY (`branchcode`) REFERENCES `branches` (`branchcode`) ON DELETE > CASCADE ON UPDATE CASCADE) at /usr/share/perl5/CGI/Emulate/PSGI.pm line 30 > at /usr/share/perl5/DBIx/Class/Exception.pm line 77 Roman, I cannot recreate this. Are you updating the database after applying the patchset? Are you taking the schema patch when you test? Lucas,
I did test once again, step by step, and got error.
Error appears when setting rule with no specific library selected in "Select a library" dropdown ("Default" is selected).
To recreate:
1. Go to Tools > Overdue notice/status triggers
2. Select "Default" in "Select a library" dropdown.
3. Set rule for any category. It works.
4. APPLY PATCH, updatedatabase, restart_all.
5. Try 1-3. It doesn't work, error is generated.
Isn't it from empty library/branch parameter (when "Default")?
After adding foreign key constraints to overduerules table "branchcode" could be only unique key from branches?
|