Bug 15473 - Koha::Objects->find should find if the key is an empty string
Summary: Koha::Objects->find should find if the key is an empty string
Status: CLOSED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: Architecture, internals, and plumbing (show other bugs)
Version: Main
Hardware: All All
: P5 - low major (vote)
Assignee: Jonathan Druart
QA Contact: Testopia
URL:
Keywords:
: 15470 (view as bug list)
Depends on: 15381
Blocks:
  Show dependency treegraph
 
Reported: 2016-01-05 15:15 UTC by Jonathan Druart
Modified: 2019-06-27 09:24 UTC (History)
3 users (show)

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


Attachments
Bug 15473: Make Koha::Objects->find accepts 0 and '' as a key (2.76 KB, patch)
2016-01-05 15:17 UTC, Jonathan Druart
Details | Diff | Splinter Review
[SIGNED-OFF] Bug 15473: Make Koha::Objects->find accepts 0 and '' as a key (2.91 KB, patch)
2016-01-05 15:37 UTC, Bernardo Gonzalez Kriegel
Details | Diff | Splinter Review
Bug 15473: Make Koha::Objects->find accepts 0 and '' as a key (2.96 KB, patch)
2016-01-08 12:42 UTC, Kyle M Hall
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Jonathan Druart 2016-01-05 15:15:15 UTC
This bug has been found after bug 15381 was pushed:
If you go on authorities/authorities.pl, you expect a form to create a authorities with a "Default" authority type.
Now, it explodes:
    Can't call method "authtypetext" on an undefined value at
    /home/koha/src/authorities/authorities.pl line 665.

Koha::Objects->find does not want to search if the key does not exist (undef, '', 0). But actually it should only be a coward if it is not defined.

Moreover this is the default behavior of the DBIx::Class find method.
Comment 1 Jonathan Druart 2016-01-05 15:17:16 UTC Comment hidden (obsolete)
Comment 2 Jonathan Druart 2016-01-05 15:33:00 UTC
*** Bug 15470 has been marked as a duplicate of this bug. ***
Comment 3 Bernardo Gonzalez Kriegel 2016-01-05 15:37:04 UTC Comment hidden (obsolete)
Comment 4 Kyle M Hall 2016-01-08 12:42:07 UTC
Created attachment 46423 [details] [review]
Bug 15473: Make Koha::Objects->find accepts 0 and '' as a key

This bug has been found after bug 15381 was pushed:
If you go on authorities/authorities.pl, you expect a form to create a
 authorities with a "Default" authority type.
Now, it explodes:
    Can't call method "authtypetext" on an undefined value at
    /home/koha/src/authorities/authorities.pl line 665.

Koha::Objects->find does not want to search if the key does not exist
(undef, '', 0). But actually it should only be a coward if it is not defined.

Moreover this is the default behavior of the DBIx::Class find method.

Test plan:
  prove t/db_dependent/Koha/Objects.t
should return green
and
  GET /cgi-bin/koha/authorities/authorities.pl
should not make everything explode.

Signed-off-by: Bernardo Gonzalez Kriegel <bgkriegel@gmail.com>
Find this after signing 15470 :)
Test pass, new auth (Default) created, no errors.

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Comment 5 Brendan Gallagher 2016-01-12 16:02:42 UTC
Pushed to Master - thanks
Comment 6 Julian Maurice 2016-01-15 08:03:06 UTC
Patch pushed to 3.22.x, will be in 3.22.2