[Bug 37510] New: Koha::Object->delete should throw a Koha::Exception if there's a parent row constraint
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=37510 Bug ID: 37510 Summary: Koha::Object->delete should throw a Koha::Exception if there's a parent row constraint Change sponsored?: --- Product: Koha Version: unspecified Hardware: All OS: All Status: NEW Severity: enhancement Priority: P5 - low Component: Architecture, internals, and plumbing Assignee: koha-bugs@lists.koha-community.org Reporter: tomascohen@gmail.com QA Contact: testopia@bugs.koha-community.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=37510 Tomás Cohen Arazi <tomascohen@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |tomascohen@gmail.com Assignee|koha-bugs@lists.koha-commun |tomascohen@gmail.com |ity.org | -- 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=37510 Tomás Cohen Arazi <tomascohen@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Depends on| |37419 Referenced Bugs: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=37419 [Bug 37419] Deleting the record source deletes the associated biblio_metadata rows -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=37510 Tomás Cohen Arazi <tomascohen@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |Needs Signoff CC| |jonathan.druart@gmail.com, | |kyle@bywatersolutions.com, | |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=37510 Tomás Cohen Arazi <tomascohen@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |nick@bywatersolutions.com, | |pedro.amorim@ptfs-europe.co | |m -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=37510 Tomás Cohen Arazi <tomascohen@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Patch complexity|--- |Small patch -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=37510 --- Comment #1 from Tomás Cohen Arazi <tomascohen@gmail.com> --- Created attachment 169829 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=169829&action=edit Bug 37510: Unit tests -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=37510 --- Comment #2 from Tomás Cohen Arazi <tomascohen@gmail.com> --- Created attachment 169830 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=169830&action=edit Bug 37510: Make Koha::Object->delete throw Koha::Exception This patch makes Koha::Object->delete wrap DBIC exceptions on FK constraints and throw a Koha::Exception::Object::FKConstraint exception instead. This will allow us better handling it from the callers. To test: 1. Apply the unit tests patch 2. Run: $ ktd --shell k$ prove t/db_dependent/Koha/Object.t => FAIL: A DBIC exception is thrown instead, tests fail 3. Apply this patch 4. Repeat 2 => SUCCESS: Tests pass! 5. Sign off :-D -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=37510 Pedro Amorim <pedro.amorim@ptfs-europe.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Needs Signoff |Failed QA --- Comment #3 from Pedro Amorim <pedro.amorim@ptfs-europe.com> --- Tests fail even after 2nd patch: t/db_dependent/Koha/Object.t .. 22/23 # Failed test 'threw Koha::Exception' # at t/db_dependent/Koha/Object.t line 1253. # expecting: Koha::Exception # found: normal exit DBIx::Class::Row::update(): Can't update Koha::Schema::Result::BiblioMetadata=HASH(0x63aab4788218): row not found at /kohadevbox/koha/Koha/Object.pm line 172 # Looks like you planned 2 tests but ran 1. # Looks like you failed 1 test of 1 run. # Failed test 'delete() tests' # at t/db_dependent/Koha/Object.t line 1261. DBIx::Class::Row::update(): Can't update Koha::Schema::Result::BiblioMetadata=HASH(0x63aab4788218): row not found at /kohadevbox/koha/Koha/Object.pm line 172 # Looks like your test exited with 255 just after 23. t/db_dependent/Koha/Object.t .. Dubious, test returned 255 (wstat 65280, 0xff00) Failed 1/23 subtests Test Summary Report ------------------- t/db_dependent/Koha/Object.t (Wstat: 65280 (exited 255) Tests: 23 Failed: 1) Failed test: 23 Non-zero exit status: 255 Files=1, Tests=23, 7 wallclock secs ( 0.03 usr 0.02 sys + 3.63 cusr 3.08 csys = 6.76 CPU) Result: FAIL -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=37510 Tomás Cohen Arazi <tomascohen@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #169829|0 |1 is obsolete| | Attachment #169830|0 |1 is obsolete| | --- Comment #4 from Tomás Cohen Arazi <tomascohen@gmail.com> --- Created attachment 169842 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=169842&action=edit Bug 37510: Unit tests -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=37510 --- Comment #5 from Tomás Cohen Arazi <tomascohen@gmail.com> --- Created attachment 169843 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=169843&action=edit Bug 37510: Make Koha::Object->delete throw Koha::Exception This patch makes Koha::Object->delete wrap DBIC exceptions on FK constraints and throw a Koha::Exception::Object::FKConstraint exception instead. This will allow us better handling it from the callers. To test: 1. Apply the unit tests patch 2. Run: $ ktd --shell k$ prove t/db_dependent/Koha/Object.t => FAIL: A DBIC exception is thrown instead, tests fail 3. Apply this patch 4. Repeat 2 => SUCCESS: Tests pass! 5. Sign off :-D -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=37510 Tomás Cohen Arazi <tomascohen@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Failed QA |Needs Signoff --- Comment #6 from Tomás Cohen Arazi <tomascohen@gmail.com> --- (In reply to Pedro Amorim from comment #3)
Tests fail even after 2nd patch:
t/db_dependent/Koha/Object.t .. 22/23 # Failed test 'threw Koha::Exception' # at t/db_dependent/Koha/Object.t line 1253. # expecting: Koha::Exception # found: normal exit DBIx::Class::Row::update(): Can't update Koha::Schema::Result::BiblioMetadata=HASH(0x63aab4788218): row not found at /kohadevbox/koha/Koha/Object.pm line 172
That's interesting. It seems to me that you don't have 37419 applied and/or missing an `updatedatabase` run. Can you retry with the newer patch (just changed the exception thrown) and provide me more context on how you're running it? Also MariaDB/MySQL version would be helpful. I've tested this with: ```shell $ docker ps | grep db-1 150d15b3232b arm64v8/mariadb:10.5 ... d2812db856b1 arm64v8/mysql:8.0 ... ``` -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=37510 Tomás Cohen Arazi <tomascohen@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Blocks| |37513 Referenced Bugs: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=37513 [Bug 37513] Deleting the record source should never display an internal server error -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=37510 David Nind <david@davidnind.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=37510 David Nind <david@davidnind.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #169842|0 |1 is obsolete| | --- Comment #7 from David Nind <david@davidnind.com> --- Created attachment 169848 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=169848&action=edit Bug 37510: Unit tests Signed-off-by: David Nind <david@davidnind.com> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=37510 David Nind <david@davidnind.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #169843|0 |1 is obsolete| | --- Comment #8 from David Nind <david@davidnind.com> --- Created attachment 169849 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=169849&action=edit Bug 37510: Make Koha::Object->delete throw Koha::Exception This patch makes Koha::Object->delete wrap DBIC exceptions on FK constraints and throw a Koha::Exception::Object::FKConstraint exception instead. This will allow us better handling it from the callers. To test: 1. Apply the unit tests patch 2. Run: $ ktd --shell k$ prove t/db_dependent/Koha/Object.t => FAIL: A DBIC exception is thrown instead, tests fail 3. Apply this patch 4. Repeat 2 => SUCCESS: Tests pass! 5. Sign off :-D Signed-off-by: David Nind <david@davidnind.com> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=37510 David Nind <david@davidnind.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |david@davidnind.com --- Comment #9 from David Nind <david@davidnind.com> --- This worked for me by running an updatedatabase after the patches were applied. Note that these warnings were there before the patches were applied: prove t/db_dependent/Koha/Object.t t/db_dependent/Koha/Object.t .. 1/23 Use of uninitialized value in numeric eq (==) at /kohadevbox/koha/Koha/Patron.pm line 446. t/db_dependent/Koha/Object.t .. 7/23 C4::Context->userenv not defined! at /kohadevbox/koha/Koha/Patron.pm line 1891. C4::Context->userenv not defined! at /kohadevbox/koha/Koha/Patron.pm line 1891. t/db_dependent/Koha/Object.t .. 9/23 DBIx::Class::Storage::DBI::insert(): Missing value for primary key column 'currency' on Currency - perhaps you forgot to set its 'is_auto_increment' attribute during add_columns()? Treating 'currency' implicitly as an autoinc, and attempting value retrieval at /kohadevbox/koha/Koha/Object.pm line 172 t/db_dependent/Koha/Object.t .. ok All tests successful. Files=1, Tests=23, 5 wallclock secs ( 0.03 usr 0.01 sys + 3.04 cusr 1.28 csys = 4.36 CPU) Result: PASS -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=37510 Pedro Amorim <pedro.amorim@ptfs-europe.com> changed: What |Removed |Added ---------------------------------------------------------------------------- QA Contact|testopia@bugs.koha-communit |pedro.amorim@ptfs-europe.co |y.org |m -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=37510 Pedro Amorim <pedro.amorim@ptfs-europe.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Signed Off |Passed QA -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=37510 Pedro Amorim <pedro.amorim@ptfs-europe.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #169848|0 |1 is obsolete| | --- Comment #10 from Pedro Amorim <pedro.amorim@ptfs-europe.com> --- Created attachment 169938 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=169938&action=edit Bug 37510: Unit tests Signed-off-by: David Nind <david@davidnind.com> Signed-off-by: Pedro Amorim <pedro.amorim@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=37510 Pedro Amorim <pedro.amorim@ptfs-europe.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #169849|0 |1 is obsolete| | --- Comment #11 from Pedro Amorim <pedro.amorim@ptfs-europe.com> --- Created attachment 169939 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=169939&action=edit Bug 37510: Make Koha::Object->delete throw Koha::Exception This patch makes Koha::Object->delete wrap DBIC exceptions on FK constraints and throw a Koha::Exception::Object::FKConstraint exception instead. This will allow us better handling it from the callers. To test: 1. Apply the unit tests patch 2. Run: $ ktd --shell k$ prove t/db_dependent/Koha/Object.t => FAIL: A DBIC exception is thrown instead, tests fail 3. Apply this patch 4. Repeat 2 => SUCCESS: Tests pass! 5. Sign off :-D Signed-off-by: David Nind <david@davidnind.com> Signed-off-by: Pedro Amorim <pedro.amorim@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=37510 --- Comment #12 from Pedro Amorim <pedro.amorim@ptfs-europe.com> --- (In reply to Tomás Cohen Arazi from comment #6)
That's interesting. It seems to me that you don't have 37419 applied and/or missing an `updatedatabase` run.
Apologies, yes I was missing the dependency. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=37510 Martin Renvoize <martin.renvoize@ptfs-europe.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Severity|enhancement |normal -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=37510 Katrin Fischer <katrin.fischer@bsz-bw.de> changed: What |Removed |Added ---------------------------------------------------------------------------- Version(s)| |24.11.00 released in| | Status|Passed QA |Pushed to main -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=37510 --- Comment #13 from Katrin Fischer <katrin.fischer@bsz-bw.de> --- Pushed for 24.11! Well done everyone, thank you! -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=37510 Katrin Fischer <katrin.fischer@bsz-bw.de> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |additional_work_needed, | |RM_priority --- Comment #14 from Katrin Fischer <katrin.fischer@bsz-bw.de> --- I believe this is related to the failing test on Jenkins: 18:27:32 koha_1 | # Failed test at t/db_dependent/Koha/Objects.t line 773. 18:27:32 koha_1 | # got: 'Koha::Exceptions::Object::FKConstraintDeletion' 18:27:32 koha_1 | # expected: 'DBIx::Class::Exception' 18:27:32 koha_1 | # Looks like you failed 1 test of 7. 18:27:32 koha_1 | 18:27:32 koha_1 | # Failed test 'Koha::Objects->delete' 18:27:32 koha_1 | # at t/db_dependent/Koha/Objects.t line 777. 18:27:32 koha_1 | # Looks like you failed 1 test of 2. 18:27:32 koha_1 | 18:27:32 koha_1 | # Failed test 'Overwritten Koha::Objects->delete - Koha::Patrons' 18:27:32 koha_1 | # at t/db_dependent/Koha/Objects.t line 778. 18:27:32 koha_1 | # Looks like you failed 1 test of 2. 18:27:32 koha_1 | 18:27:32 koha_1 | # Failed test 'Delete' 18:27:32 koha_1 | # at t/db_dependent/Koha/Objects.t line 782. 18:27:32 koha_1 | # Looks like you failed 1 test of 2. 18:27:32 koha_1 | 18:27:32 koha_1 | # Failed test 'Return same values as DBIx::Class' 18:27:32 koha_1 | # at t/db_dependent/Koha/Objects.t line 1065. 18:27:32 koha_1 | # Looks like you failed 1 test of 23. 18:27:32 koha_1 | [16:25:57] t/db_dependent/Koha/Objects.t ............................................... 18:27:32 koha_1 | Dubious, test returned 1 (wstat 256, 0x100) 18:27:32 koha_1 | Failed 1/23 subtests -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=37510 --- Comment #15 from Tomás Cohen Arazi <tomascohen@gmail.com> --- Created attachment 170464 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=170464&action=edit Bug 37510: Fix Objects.t and remove FIXME This patch makes the tests check for the added exception instead of the generic DBIx::Class::Exception. A FIXME was set in place proposing we should throw a Koha::Exception instead, so removing the FIXME as that's what this patch actually did. Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=37510 Katrin Fischer <katrin.fischer@bsz-bw.de> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords|additional_work_needed, | |RM_priority | --- Comment #16 from Katrin Fischer <katrin.fischer@bsz-bw.de> --- Pushed follow-up, thanks! -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=37510 Lucas Gass <lucas@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |lucas@bywatersolutions.com Status|Pushed to main |Pushed to stable Version(s)|24.11.00 |24.11.00,24.05.04 released in| | --- Comment #17 from Lucas Gass <lucas@bywatersolutions.com> --- Backported to 24.05.x for upcoming 24.05.04 -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=37510 Fridolin Somers <fridolin.somers@biblibre.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |fridolin.somers@biblibre.co | |m Status|Pushed to stable |Needs documenting --- Comment #18 from Fridolin Somers <fridolin.somers@biblibre.com> --- Depends on Bug 37419 not in 23.11.x -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=37510 David Nind <david@davidnind.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Needs documenting |RESOLVED Resolution|--- |FIXED --- Comment #19 from David Nind <david@davidnind.com> --- No changes required to the manual. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=37510 Bug 37510 depends on bug 37419, which changed state. Bug 37419 Summary: Deleting the record source deletes the associated biblio_metadata rows https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=37419 What |Removed |Added ---------------------------------------------------------------------------- Status|Needs documenting |RESOLVED Resolution|--- |FIXED -- You are receiving this mail because: You are watching all bug changes.
participants (1)
-
bugzilla-daemon@bugs.koha-community.org