Bug 22679

Summary: circulation_rules are not deleted when accompanying issuingrules are deleted
Product: Koha Reporter: Nick Clemens (kidclamp) <nick>
Component: CirculationAssignee: Nick Clemens (kidclamp) <nick>
Status: CLOSED FIXED QA Contact: Testopia <testopia>
Severity: critical    
Priority: P5 - low CC: gmcharlt, jonathan.druart, julian.maurice, katrin.fischer, kyle.m.hall, m.de.rooy, martin.renvoize, tomascohen
Version: Main   
Hardware: All   
OS: All   
See Also: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=18928
Change sponsored?: --- Patch complexity: Small patch
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
19.05.00
Bug Depends on: 18925    
Bug Blocks:    
Attachments: Bug 22679: Delete related CirculationRules when Removing IssuingRule
Bug 22679: Delete related CirculationRules when Removing IssuingRule
Bug 22679: Delete related CirculationRules when Removing IssuingRule

Description Nick Clemens (kidclamp) 2019-04-10 13:49:56 UTC
To recreate:
1 - Browse to Administration ->Circulation and fines
2 - Add a rule with a number for 'Total checkouts allowed'
3 - check the db:
    select * from circulation_rules
4 - The rule should be there
5 - Delete the rule from the staff interface
6 - Check the DB
7 - The rule is not deleted
Comment 1 Nick Clemens (kidclamp) 2019-04-23 14:22:06 UTC
Created attachment 88489 [details] [review]
Bug 22679: Delete related CirculationRules when Removing IssuingRule

Unfortunately, the tables here can't use a foreign key as one table uses null where the other uses
'*' This patchset alters the delete method so delete related rules. It is somewhat of a workaround until
all the columns in issuingrules are moved to circulation_rules

To test:
1 - Add some issuing rules in koha, making sure to set maxissueqty
2 - Check the DB: SELECT * FROM circulation_rules;
3 - note some circulation rules were created
4 - Delete your rules via the staff interface
5 - Check the DB, the circulation rules remain
6 - Apply patch
7 - Repeat
8 - Huzzah! The rules delete!
9 - Prove the tests, read the code
Comment 2 Tomás Cohen Arazi 2019-04-23 14:58:08 UTC
I think this is a good workaround. As we are removing issuingrules (I think Jonathan submitted patches to complete that already) I think we can live with this for a little.
Comment 3 Liz Rea 2019-04-23 16:09:34 UTC
Created attachment 88529 [details] [review]
Bug 22679: Delete related CirculationRules when Removing IssuingRule

Unfortunately, the tables here can't use a foreign key as one table uses null where the other uses
'*' This patchset alters the delete method so delete related rules. It is somewhat of a workaround until
all the columns in issuingrules are moved to circulation_rules

To test:
1 - Add some issuing rules in koha, making sure to set maxissueqty
2 - Check the DB: SELECT * FROM circulation_rules;
3 - note some circulation rules were created
4 - Delete your rules via the staff interface
5 - Check the DB, the circulation rules remain
6 - Apply patch
7 - Repeat
8 - Huzzah! The rules delete!
9 - Prove the tests, read the code

Signed-off-by: Liz Rea <wizzyrea@gmail.com>
Comment 4 Katrin Fischer 2019-04-23 21:13:49 UTC
Created attachment 88567 [details] [review]
Bug 22679: Delete related CirculationRules when Removing IssuingRule

Unfortunately, the tables here can't use a foreign key as one table uses null where the other uses
'*' This patchset alters the delete method so delete related rules. It is somewhat of a workaround until
all the columns in issuingrules are moved to circulation_rules

To test:
1 - Add some issuing rules in koha, making sure to set maxissueqty
2 - Check the DB: SELECT * FROM circulation_rules;
3 - note some circulation rules were created
4 - Delete your rules via the staff interface
5 - Check the DB, the circulation rules remain
6 - Apply patch
7 - Repeat
8 - Huzzah! The rules delete!
9 - Prove the tests, read the code

Signed-off-by: Liz Rea <wizzyrea@gmail.com>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Comment 5 Nick Clemens (kidclamp) 2019-04-24 11:43:10 UTC
Awesome work all!

Pushed to master for 19.05
Comment 6 Martin Renvoize 2019-04-26 14:47:05 UTC
Bug with enhancement not in 18.11.x series.
Comment 7 Jonathan Druart 2019-05-03 21:15:16 UTC
See bug 18928 comment 37 for a follow-up on this, we should not delete all rules.
Comment 8 Jonathan Druart 2019-05-24 21:42:00 UTC
We should delete in a transaction and handle the returned value.