Bug 14205

Summary: Deleting an Item/Record does not remove link to course reserve
Product: Koha Reporter: Tom Misilo <tmisilo>
Component: Course reservesAssignee: Jonathan Druart <jonathan.druart>
Status: CLOSED FIXED QA Contact: Testopia <testopia>
Severity: major    
Priority: P3 CC: chris, jonathan.druart, katrin.fischer, kyle.m.hall, kyle, liz, tmisilo, tomascohen
Version: master   
Hardware: All   
OS: All   
Change sponsored?: --- Patch complexity: ---
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
Bug Depends on: 8215    
Bug Blocks: 15207    
Attachments: Bug 14205: Deleting an Item/Record does not remove link to course reserve
Bug 14205: Deleting an Item/Record does not remove link to course reserve
[PASSED QA] Bug 14205: Deleting an Item/Record does not remove link to course reserve
Bug 14205: (RM followup) DBIx updates

Description Tom Misilo 2015-05-14 22:37:29 UTC
Steps to Reproduce:

1. Login to Staff Site.
2. Go to Course Reserves
3. Create Course
4. Add Reserve
5. Go to item added (delete item/record)
6. Refresh Course (see no items attached)
7. Delete Course
8. See course still listed in the courses (Not deleted)

I tested on 3.18.5 and 3.19.00.016

When deleting an item/record it does not remove the link from the course reserves, making it so you cannot remove the course even though it shows no items attached.
Comment 1 Tom Misilo 2015-05-27 13:34:26 UTC
I believe it is deleting the item from course_items per the CASCADE DELETE in the Model, however the http://schema.koha-community.org/tables/course_reserves.html course_reserves table is not being cleaned up via a cascade delete (No contraint defined)

course_reserves.ci_id -> course_items.ci_id
Comment 2 Jonathan Druart 2015-07-14 11:16:40 UTC
Kyle, I think it makes sense to add this constraint, do you agree?
Comment 3 Kyle M Hall 2015-07-16 14:20:41 UTC
(In reply to Jonathan Druart from comment #2)
> Kyle, I think it makes sense to add this constraint, do you agree?

Absolutely!
Comment 4 Jonathan Druart 2015-08-04 09:03:56 UTC Comment hidden (obsolete)
Comment 5 Mark Tompsett 2015-08-05 20:04:11 UTC Comment hidden (obsolete)
Comment 6 Katrin Fischer 2015-09-02 06:17:44 UTC
Created attachment 42190 [details] [review]
[PASSED QA] Bug 14205: Deleting an Item/Record does not remove link to course reserve

A constraint is missing on the course_reserves.ci_id field.
This patch adds it and removes orphan rows.

Test plan:
0/ Don't apply the patch
1/ Login to Staff Site.
2/ Go to Course Reserves
3/ Create Course
4/ Add Reserve
5/ Go to item added (delete item/record)
6/ Refresh Course (see no items attached)
7/ Delete Course
8/ See course still listed in the courses (Not deleted)
9/ Apply the patch and execute the updatedatabase entry.
10/ Delete the Course
Note that the course has correctly been removed.

NOTE: Make sure to set the UseCourseReserves system preference to test.
      Tested before (problem existed) and after (problem solved) update.
      Dropped DB, web installed, and put in dummy data and retested.
      Problem solved.

Signed-off-by: Mark Tompsett <mtompset@hotmail.com>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Comment 7 Tomás Cohen Arazi 2015-09-02 12:50:10 UTC
Created attachment 42221 [details] [review]
Bug 14205: (RM followup) DBIx updates

Signed-off-by: Tomas Cohen Arazi <tomascohen@unc.edu.ar>
Comment 8 Tomás Cohen Arazi 2015-09-02 14:09:26 UTC
Patch pushed to master.

Thanks Jonathan!
Comment 9 Tom Misilo 2015-09-16 17:39:18 UTC
Could this be back ported to 3.18?
Comment 10 Jonathan Druart 2015-09-17 06:39:10 UTC
(In reply to Tom Misilo from comment #9)
> Could this be back ported to 3.18?

CCing RM 3.20 and 3.18
Comment 11 Liz Rea 2015-09-17 21:45:16 UTC
I'll give it a try on 3.18.
Comment 12 Liz Rea 2015-09-21 02:44:16 UTC
Pushed to 3.18.x will be in 3.18.11.

If someone wouldn't mind checking over the 3.18 branch with these, it was my first go at updating the schema files and I'd appreciate someone confirming that I've done it correctly.
Comment 13 Liz Rea 2015-09-21 02:44:42 UTC
(Also leaving this 'pushed to master' to flag it for 3.20)

Liz
Comment 14 Chris Cormack 2015-09-22 01:24:36 UTC
Pushed to 3.20.x will be in 3.20.4
Comment 15 Tom Misilo 2015-09-22 11:11:21 UTC
Thank you. It is much appreciated!
Comment 16 Jonathan Druart 2016-01-11 16:31:26 UTC
Note that there is a failure when updating from 3.18 to 3.20:

DBD::mysql::db do failed: Duplicate entry '1-self_checkout' for key 'PRIMARY' at /usr/share/koha/intranet/cgi-bin/installer/data/mysql/updatedatabase.pl line 10614.
Upgrade to 3.20.03.003 done (Bug 14298: AutoSelfCheckID user should only be able to access SCO )

see https://lists.katipo.co.nz/pipermail/koha/2016-January/044539.html
Comment 17 Jonathan Druart 2016-01-11 16:32:33 UTC
Sorry, c/p the wrong error:

DBD::mysql::db do failed: Can't create table 'koha_library.#sql-4b9_42' (errno: 121) at /usr/share/koha/intranet/cgi-bin/installer/data/mysql/updatedatabase.pl line 10584.
Upgrade to 3.20.03.001 done (Bug 14205: Deleting an Item/Record does not remove link to course reserve)