Bug 15270

Summary: Koha::Objects->find can exploded if searching for nonexistent record
Product: Koha Reporter: Jonathan Druart <jonathan.druart>
Component: Architecture, internals, and plumbingAssignee: Jonathan Druart <jonathan.druart>
Status: CLOSED FIXED QA Contact: Testopia <testopia>
Severity: normal    
Priority: P5 - low CC: f.demians
Version: Main   
Hardware: All   
OS: All   
See Also: http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=15473
Change sponsored?: --- Patch complexity: Small patch
Documentation contact: Documentation submission:
Text to go in the release notes:
On 3.20.05, if AnonymousPatron is set to a nonexistent borrowernumber, the about.pl crashes with: DBIC result type isn't of the type Borrower at /home/koha/src/Koha/Objects.pm line 87.
Version(s) released in:
Circulation function:
Attachments: Bug 15270: Make Koha::Objects->find return undef instead of crashing
Bug 15270: Add regression tests for Koha::Objects->find
[FOR 3.20.X ONLY] Bug 15270: Make Koha::Objects->find return undef instead of crashing
Bug 15270: Make Koha::Objects->find return undef instead of crashing
Bug 15270: Add regression tests for Koha::Objects->find
[PASSED QA] Bug 15270: Make Koha::Objects->find return undef instead of crashing
[PASSED QA] Bug 15270: Add regression tests for Koha::Objects->find

Description Jonathan Druart 2015-12-01 10:08:13 UTC
On 3.20.05, if AnonymousPatron is set to a nonexistent borrowernumber, the about.pl crashes with

  DBIC result type  isn't of the type Borrower at /home/koha/src/Koha/Objects.pm line 87.

This was fixed on master by

commit 6882949b1b3bd1284e3d2877244a64edee3883ca
Date:   Wed Apr 8 06:38:34 2015 -0400
    Bug 13967 - System preferences need a package
Comment 1 Jonathan Druart 2015-12-01 10:15:31 UTC Comment hidden (obsolete)
Comment 2 Jonathan Druart 2015-12-01 10:17:52 UTC Comment hidden (obsolete)
Comment 3 Jonathan Druart 2015-12-01 10:18:10 UTC Comment hidden (obsolete)
Comment 4 Jonathan Druart 2015-12-01 10:19:26 UTC
The 2 patches are for 3.20.x but it would be good to get the first one (the tests) on master too.
Comment 5 Magnus Enger 2015-12-01 13:54:45 UTC Comment hidden (obsolete)
Comment 6 Magnus Enger 2015-12-01 13:56:06 UTC Comment hidden (obsolete)
Comment 7 Frédéric Demians 2015-12-02 07:12:24 UTC
(In reply to Jonathan Druart from comment #4)
> The 2 patches are for 3.20.x but it would be good to get the first one (the
> tests) on master too.

I can see the bug and the solution. Can I QA myself those patches, and then pushed them on 3.20, am I supposed to wait someone else from the QA team to validate this before?
Comment 8 Jonathan Druart 2015-12-02 08:24:00 UTC
(In reply to Frédéric Demians from comment #7)
> (In reply to Jonathan Druart from comment #4)
> > The 2 patches are for 3.20.x but it would be good to get the first one (the
> > tests) on master too.
> 
> I can see the bug and the solution. Can I QA myself those patches, and then
> pushed them on 3.20, am I supposed to wait someone else from the QA team to
> validate this before?

I don't know, I think the RMaints have the responsibility of keeping their branch stable :)
Since you are releasing at the end of the month, maybe it is worth to wait for another pair of eyes?
Comment 9 Katrin Fischer 2015-12-02 23:22:12 UTC
Please wait for the QA team. If something is urgently needed, feel free to nudge me or one of the others about it.
Comment 10 Frédéric Demians 2015-12-03 06:23:21 UTC
(In reply to Katrin Fischer from comment #9)
> Please wait for the QA team. If something is urgently needed, feel free to
> nudge me or one of the others about it.

OK
Comment 11 Katrin Fischer 2015-12-06 21:31:02 UTC
Created attachment 45438 [details] [review]
[PASSED QA] Bug 15270: Make Koha::Objects->find return undef instead of crashing

On 3.20.05, if AnonymousPatron is set to a nonexistent borrowernumber, the about.pl crashes with

  DBIC result type  isn't of the type Borrower at /home/koha/src/Koha/Objects.pm line 87.

This was fixed on master by
  commit 6882949b1b3bd1284e3d2877244a64edee3883ca
  Date:   Wed Apr 8 06:38:34 2015 -0400
      Bug 13967 - System preferences need a package

Test plan:
Set the AnonymousPatron pref to a nonexistent borrowernumber
Go on about.pl
Without this patch, you get the error.

Signed-off-by: Magnus Enger <magnus@libriotech.no>
Set AnonymousPatron pref to a nonexistent borrowernumber. Before the
patch, about.pl shows a nasty error. After applying the patch the
error is gone. Tests in t/db_dependent/Objects.t pass.

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Comment 12 Katrin Fischer 2015-12-06 21:31:30 UTC
Created attachment 45439 [details] [review]
[PASSED QA] Bug 15270: Add regression tests for Koha::Objects->find

Signed-off-by: Magnus Enger <magnus@libriotech.no>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Comment 13 Frédéric Demians 2015-12-07 06:33:01 UTC
This patch has been pushed to 3.20.x, will be in 3.20.7.