Bug 17820 - Do not use search->next when find can be used
Summary: Do not use search->next when find can be used
Status: RESOLVED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: Architecture, internals, and plumbing (show other bugs)
Version: master
Hardware: All All
: P5 - low normal (vote)
Assignee: Jonathan Druart
QA Contact: Marcel de Rooy
URL:
Whiteboard:
Keywords:
Depends on: 16276
Blocks: 17819
  Show dependency treegraph
 
Reported: 2016-12-28 13:31 UTC by Jonathan Druart
Modified: 2017-06-14 22:18 UTC (History)
3 users (show)

See Also:
Change sponsored?: ---
Patch complexity: Trivial patch
Bot Control: ---
When did the bot last check this:
Who signed the patch off:
Text to go in the release notes:


Attachments
Bug 17820: use ->find instead of search->next (1.09 KB, patch)
2016-12-28 13:34 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 17820: use ->find instead of search->next (1.29 KB, patch)
2016-12-29 10:42 UTC, Marcel de Rooy
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-12-28 13:31:04 UTC
From C4::Auth:
  my $patron = Koha::Patrons->search({ userid => $userid })->next;

This should be replaced with
  my $patron = Koha::Patrons->find({ userid => $userid });

userid is a unique key
Comment 1 Jonathan Druart 2016-12-28 13:34:20 UTC
Created attachment 58466 [details] [review]
Bug 17820: use ->find instead of search->next

From C4::Auth:
  my $patron = Koha::Patrons->search({ userid => $userid })->next;

This should be replaced with
  my $patron = Koha::Patrons->find({ userid => $userid });

userid is a unique key

Caught with NYTProf:
 # spent 78.9ms making 1 call to Koha::Objects::next

Test plan:
Login at the intranet
Reload the page
=> You must still be logged in
Comment 2 Marcel de Rooy 2016-12-29 10:42:26 UTC
Created attachment 58487 [details] [review]
Bug 17820: use ->find instead of search->next

From C4::Auth:
  my $patron = Koha::Patrons->search({ userid => $userid })->next;

This should be replaced with
  my $patron = Koha::Patrons->find({ userid => $userid });

userid is a unique key

Caught with NYTProf:
 # spent 78.9ms making 1 call to Koha::Objects::next

Test plan:
Login at the intranet
Reload the page
=> You must still be logged in

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Tested by enabling TrackLastPatronActivity and logging in again.
Verified lastseen column in borrowers.
Comment 3 Marcel de Rooy 2016-12-29 10:43:26 UTC
Passing QA on this trivial patch in one run. Works fine.
Comment 4 Kyle M Hall 2016-12-30 11:51:04 UTC
Pushed to master for 17.05, thanks Jonathan!
Comment 5 Katrin Fischer 2017-01-04 21:55:24 UTC
This patch has been pushed to 16.11.x and will be in 16.11.02.