Bug 34918 - Koha/Items.t crashes on missing borrower 42 or 51
Summary: Koha/Items.t crashes on missing borrower 42 or 51
Status: Pushed to oldstable
Alias: None
Product: Koha
Classification: Unclassified
Component: Architecture, internals, and plumbing (show other bugs)
Version: Main
Hardware: All All
: P5 - low minor (vote)
Assignee: Marcel de Rooy
QA Contact: Katrin Fischer
URL:
Keywords:
Depends on:
Blocks: 34933
  Show dependency treegraph
 
Reported: 2023-09-26 14:21 UTC by Marcel de Rooy
Modified: 2023-10-17 13:37 UTC (History)
1 user (show)

See Also:
Change sponsored?: ---
Patch complexity: Trivial patch
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:
23.11.00,23.05.05,22.11.11


Attachments
Bug 34918: Fix hardcoded borrowernumber 42 (1.27 KB, patch)
2023-09-26 14:42 UTC, Marcel de Rooy
Details | Diff | Splinter Review
Bug 34918: Fix hardcoded borrowernumber 42 (1.31 KB, patch)
2023-09-27 11:13 UTC, Marcel de Rooy
Details | Diff | Splinter Review
Bug 34918: Fix userenv for safe_to_delete tests (1.44 KB, patch)
2023-09-27 11:13 UTC, Marcel de Rooy
Details | Diff | Splinter Review
Bug 34918: Fix hardcoded borrowernumber 42 (1.33 KB, patch)
2023-09-29 11:35 UTC, Katrin Fischer
Details | Diff | Splinter Review
Bug 34918: Fix userenv for safe_to_delete tests (1.46 KB, patch)
2023-09-29 11:35 UTC, Katrin Fischer
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Marcel de Rooy 2023-09-26 14:21:40 UTC
$dbh->do("INSERT INTO tmp_holdsqueue (surname,borrowernumber,itemnumber) VALUES ('Clamp',42,$itemnumber)");

This is really ugly :)
Especially if you dont have the sample patrons with borrower 42..
Comment 1 Marcel de Rooy 2023-09-26 14:31:26 UTC
Test::Builder::subtest(): DBI Exception: DBD::mysql::db do failed: Cannot add or update a child row: a foreign key constraint fails (`koha_myclone`.`tmp_holdsqueue`, CONSTRAINT `tmp_holdsqueue_ibfk_3` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE) at /usr/share/perl/5.32/Test/More.pm line 809
Comment 2 Marcel de Rooy 2023-09-26 14:41:22 UTC
Apart from a simple fix for 41, it also stumbles on a missing 51 later on for safe_to_delete.

Can't call method "can_edit_items_from" on an undefined value at /usr/share/koha/Koha/Item.pm line 299.
Comment 3 Marcel de Rooy 2023-09-26 14:42:53 UTC
Created attachment 156234 [details] [review]
Bug 34918: Fix hardcoded borrowernumber 42

Test plan:
Run t/db_dependent/Koha/Item.t
Comment 4 Marcel de Rooy 2023-09-26 14:43:26 UTC
WIP: The problem with safe_to_delete must be solved too.
Comment 5 Marcel de Rooy 2023-09-27 11:13:54 UTC
Created attachment 156281 [details] [review]
Bug 34918: Fix hardcoded borrowernumber 42

Test plan:
Run t/db_dependent/Koha/Item.t

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Comment 6 Marcel de Rooy 2023-09-27 11:13:56 UTC
Created attachment 156282 [details] [review]
Bug 34918: Fix userenv for safe_to_delete tests

Instead of the fallback to 51, we pass a borrower that has
permission for editing items.

Test plan:
Do not apply patch.
Run test without a borrower 51 in db. (FAIL)
Apply patch.
Run test again. (PASS)

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Comment 7 Marcel de Rooy 2023-09-27 11:14:25 UTC
Trivial: Self SO.
Comment 8 Katrin Fischer 2023-09-29 11:35:15 UTC
Created attachment 156382 [details] [review]
Bug 34918: Fix hardcoded borrowernumber 42

Test plan:
Run t/db_dependent/Koha/Item.t

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
Comment 9 Katrin Fischer 2023-09-29 11:35:17 UTC
Created attachment 156383 [details] [review]
Bug 34918: Fix userenv for safe_to_delete tests

Instead of the fallback to 51, we pass a borrower that has
permission for editing items.

Test plan:
Do not apply patch.
Run test without a borrower 51 in db. (FAIL)
Apply patch.
Run test again. (PASS)

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
Comment 10 Tomás Cohen Arazi 2023-10-03 12:55:29 UTC
Pushed to master for 23.11.

Nice work everyone, thanks!
Comment 11 Fridolin Somers 2023-10-05 19:21:33 UTC
Pushed to 23.05.x for 23.05.05
Comment 12 Jacob O'Mara 2023-10-17 13:37:55 UTC
Nice work everyone!

Pushed to oldstable for 22.11.x