[Bug 21674] New: Data integrity not enforced for library groups
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=21674 Bug ID: 21674 Summary: Data integrity not enforced for library groups Change sponsored?: --- Product: Koha Version: unspecified Hardware: All OS: All Status: NEW Severity: major Priority: P5 - low Component: Architecture, internals, and plumbing Assignee: koha-bugs@lists.koha-community.org Reporter: jonathan.druart@bugs.koha-community.org QA Contact: testopia@bugs.koha-community.org Depends on: 15707 You can create hierarchical groups of libraries you are not allowed to add several times the same library to a given group/subgroup. The libraries that are part of the group is not displayed on the interface, to prevent the user to select it. However this restriction is only done template-side, the controller and module does not handle it. To recreate the problem: - Go to Home › Administration › Library groups - Add a group - Add a library - reload the page several times => The same library appears several times in the group Note that we should also replace the "Add" and "Remove" links with buttons. Referenced Bugs: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=15707 [Bug 15707] Add ability to define hierarchical groups of libraries -- You are receiving this mail because: You are the assignee for the bug. You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=21674 Jonathan Druart <jonathan.druart@bugs.koha-community.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |Needs Signoff -- You are receiving this mail because: You are watching all bug changes. You are the assignee for the bug.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=21674 --- Comment #1 from Jonathan Druart <jonathan.druart@bugs.koha-community.org> --- Created attachment 96199 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=96199&action=edit Bug 21674: DB changes -- You are receiving this mail because: You are watching all bug changes. You are the assignee for the bug.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=21674 --- Comment #2 from Jonathan Druart <jonathan.druart@bugs.koha-community.org> --- Created attachment 96200 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=96200&action=edit Bug 21674: Prevent to insert twice the same library in a group You can create hierarchical groups of libraries you are not allowed to add several times the same library to a given group/subgroup. The libraries that are part of the group is not displayed on the interface, to prevent the user to select it. However this restriction is only done template-side, the controller and module does not handle it. To prevent that this patchset enforces the constraint at DB level, and display a message to the end user. Test plan: - Go to Home › Administration › Library groups - Add a group - Add a library - reload the page several times => Without this patch the same library appears several times in the group => With this patch applied you will see a friendly error message -- You are receiving this mail because: You are watching all bug changes. You are the assignee for the bug.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=21674 Jonathan Druart <jonathan.druart@bugs.koha-community.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Assignee|koha-bugs@lists.koha-commun |jonathan.druart@bugs.koha-c |ity.org |ommunity.org -- You are receiving this mail because: You are the assignee for the bug. You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=21674 Nick Clemens <nick@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Needs Signoff |Failed QA CC| |nick@bywatersolutions.com --- Comment #3 from Nick Clemens <nick@bywatersolutions.com> --- Tested on a sandbox, did not work -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=21674 Nick Clemens <nick@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Failed QA |Patch doesn't apply -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=21674 Jonathan Druart <jonathan.druart@bugs.koha-community.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Patch doesn't apply |Needs Signoff -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=21674 Jonathan Druart <jonathan.druart@bugs.koha-community.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #96200|0 |1 is obsolete| | --- Comment #4 from Jonathan Druart <jonathan.druart@bugs.koha-community.org> --- Created attachment 97658 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=97658&action=edit Bug 21674: Prevent to insert twice the same library in a group You can create hierarchical groups of libraries you are not allowed to add several times the same library to a given group/subgroup. The libraries that are part of the group is not displayed on the interface, to prevent the user to select it. However this restriction is only done template-side, the controller and module does not handle it. To prevent that this patchset enforces the constraint at DB level, and display a message to the end user. Test plan: - Go to Home › Administration › Library groups - Add a group - Add a library - reload the page several times => Without this patch the same library appears several times in the group => With this patch applied you will see a friendly error message -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=21674 --- Comment #5 from Jonathan Druart <jonathan.druart@bugs.koha-community.org> --- (In reply to Nick Clemens from comment #3)
Tested on a sandbox, did not work
Works for me, please try again with this rebased patch. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=21674 Nick Clemens <nick@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Needs Signoff |Failed QA --- Comment #6 from Nick Clemens <nick@bywatersolutions.com> --- If a library is duplicated in the group before this patch then the DB update fails - we need to cleanup before adding the constraint -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=21674 Jonathan Druart <jonathan.druart@bugs.koha-community.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Failed QA |Needs Signoff -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=21674 --- Comment #7 from Jonathan Druart <jonathan.druart@bugs.koha-community.org> --- Created attachment 97667 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=97667&action=edit Bug 21674: Remove duplicates from library_groups before adding the uniq constraint To avoid to make it fails if duplicates existed prior to this change -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=21674 --- Comment #8 from Jonathan Druart <jonathan.druart@bugs.koha-community.org> --- (In reply to Jonathan Druart from comment #7)
Created attachment 97667 [details] [review] Bug 21674: Remove duplicates from library_groups before adding the uniq constraint
To avoid to make it fails if duplicates existed prior to this change
There is certainly a more efficient (SQL) way to do that. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=21674 --- Comment #9 from Nick Clemens <nick@bywatersolutions.com> --- (In reply to Jonathan Druart from comment #8)
(In reply to Jonathan Druart from comment #7)
Created attachment 97667 [details] [review] [review] Bug 21674: Remove duplicates from library_groups before adding the uniq constraint
To avoid to make it fails if duplicates existed prior to this change
There is certainly a more efficient (SQL) way to do that.
DELETE FROM library_groups WHERE id NOT IN (SELECT MIN(id) FROM library_groups WHERE parent_id IS NOT NULL GROUP BY parent_id,branchcode) AND parent_id IS NOT NULL; -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=21674 Jonathan Druart <jonathan.druart@bugs.koha-community.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #97667|0 |1 is obsolete| | --- Comment #10 from Jonathan Druart <jonathan.druart@bugs.koha-community.org> --- Created attachment 97811 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=97811&action=edit Bug 21674: Remove duplicates from library_groups before adding the uniq constraint To avoid to make it fails if duplicates existed prior to this change Credit for the SQL query goes to Nick, thanks! -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=21674 Nick Clemens <nick@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Needs Signoff |Signed Off -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=21674 Nick Clemens <nick@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #96199|0 |1 is obsolete| | Attachment #97658|0 |1 is obsolete| | Attachment #97811|0 |1 is obsolete| | --- Comment #11 from Nick Clemens <nick@bywatersolutions.com> --- Created attachment 97837 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=97837&action=edit Bug 21674: DB changes Signed-off-by: Nick Clemens <nick@bywatersolutions.com> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=21674 --- Comment #12 from Nick Clemens <nick@bywatersolutions.com> --- Created attachment 97838 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=97838&action=edit Bug 21674: Prevent to insert twice the same library in a group You can create hierarchical groups of libraries you are not allowed to add several times the same library to a given group/subgroup. The libraries that are part of the group is not displayed on the interface, to prevent the user to select it. However this restriction is only done template-side, the controller and module does not handle it. To prevent that this patchset enforces the constraint at DB level, and display a message to the end user. Test plan: - Go to Home › Administration › Library groups - Add a group - Add a library - reload the page several times => Without this patch the same library appears several times in the group => With this patch applied you will see a friendly error message Signed-off-by: Nick Clemens <nick@bywatersolutions.com> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=21674 --- Comment #13 from Nick Clemens <nick@bywatersolutions.com> --- Created attachment 97839 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=97839&action=edit Bug 21674: Remove duplicates from library_groups before adding the uniq constraint To avoid to make it fails if duplicates existed prior to this change Credit for the SQL query goes to Nick, thanks! Signed-off-by: Nick Clemens <nick@bywatersolutions.com> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=21674 Martin Renvoize <martin.renvoize@ptfs-europe.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #97837|0 |1 is obsolete| | --- Comment #14 from Martin Renvoize <martin.renvoize@ptfs-europe.com> --- Created attachment 98170 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=98170&action=edit Bug 21674: DB changes Signed-off-by: Nick Clemens <nick@bywatersolutions.com> Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=21674 Martin Renvoize <martin.renvoize@ptfs-europe.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #97838|0 |1 is obsolete| | --- Comment #15 from Martin Renvoize <martin.renvoize@ptfs-europe.com> --- Created attachment 98171 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=98171&action=edit Bug 21674: Prevent to insert twice the same library in a group When you create hierarchical groups of libraries you are not allowed to add several times the same library to a given group/subgroup. The libraries that are part of the group is not displayed on the interface, to prevent the user to select it. However this restriction is only done template-side, the controller and module does not handle it. To prevent that this patchset enforces the constraint at DB level, and display a message to the end user. Test plan: - Go to Home › Administration › Library groups - Add a group - Add a library - reload the page several times => Without this patch the same library appears several times in the group => With this patch applied you will see a friendly error message Signed-off-by: Nick Clemens <nick@bywatersolutions.com> Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=21674 Martin Renvoize <martin.renvoize@ptfs-europe.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #97839|0 |1 is obsolete| | --- Comment #16 from Martin Renvoize <martin.renvoize@ptfs-europe.com> --- Created attachment 98172 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=98172&action=edit Bug 21674: Remove duplicates from library_groups before adding the uniq constraint To avoid to make it fails if duplicates existed prior to this change Credit for the SQL query goes to Nick, thanks! Signed-off-by: Nick Clemens <nick@bywatersolutions.com> Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=21674 Martin Renvoize <martin.renvoize@ptfs-europe.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |martin.renvoize@ptfs-europe | |.com Status|Signed Off |Passed QA --- Comment #17 from Martin Renvoize <martin.renvoize@ptfs-europe.com> --- Nice teamwork guys.. all works as expected. Passing QA -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=21674 Martin Renvoize <martin.renvoize@ptfs-europe.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Version(s)| |20.05.00 released in| | Status|Passed QA |Pushed to master -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=21674 --- Comment #18 from Martin Renvoize <martin.renvoize@ptfs-europe.com> --- Nice work everyone! Pushed to master for 20.05 -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=21674 Martin Renvoize <martin.renvoize@ptfs-europe.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |additional_work_needed --- Comment #19 from Martin Renvoize <martin.renvoize@ptfs-europe.com> --- I'm getting a wierd DB error on this one: DBD::mysql::db do failed: Table 'library_groups' is specified twice, both as a target for 'DELETE' and as a separate source for data [for Statement " DELETE FROM library_groups WHERE id NOT IN ( SELECT MIN(id) FROM library_groups WHERE parent_id IS NOT NULL GROUP BY parent_id, branchcode ) AND parent_id IS NOT NULL; "] at ./installer/data/mysql/updatedatabase.pl line 20666. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=21674 --- Comment #20 from Martin Renvoize <martin.renvoize@ptfs-europe.com> --- Created attachment 98224 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=98224&action=edit Bug 21674: (RM follow-up) Fix updatedatabase error -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=21674 Jonathan Druart <jonathan.druart@bugs.koha-community.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Blocks| |24741 Referenced Bugs: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=24741 [Bug 24741] Recent creation of unique index on library_groups erroneously removes rows -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=21674 Jonathan Druart <jonathan.druart@bugs.koha-community.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords|additional_work_needed | -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=21674 Fridolin Somers <fridolin.somers@biblibre.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Pushed to master |RESOLVED Resolution|--- |FIXED -- You are receiving this mail because: You are watching all bug changes.
participants (1)
-
bugzilla-daemon@bugs.koha-community.org