Bug 8219

Summary: get_biblio_authorised_values embarrassingly inefficient
Product: Koha Reporter: Jared Camins-Esakov <jcamins>
Component: Architecture, internals, and plumbingAssignee: Galen Charlton <gmcharlt>
Status: CLOSED FIXED QA Contact:
Severity: normal    
Priority: P5 - low CC: jonathan.druart, katrin.fischer, tomascohen
Version: Main   
Hardware: All   
OS: All   
See Also: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=16167
Change sponsored?: --- Patch complexity: ---
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
Bug Depends on: 7923    
Bug Blocks:    

Description Jared Camins-Esakov 2012-06-10 00:39:00 UTC
The routine C4::Biblio::get_biblio_authorised_values is horrifyingly inefficient. In a relatively low-powered system with a large number of authorized values, exclusive time in get_biblio_authorised_values can be several seconds or more when doing a search, since the routine is called once per result.
Comment 1 Katrin Fischer 2019-04-28 14:00:03 UTC
It looks like there is only one occurence of this method in the current codebase, but sadly it's Search.pm:

C4/Search.pm:        $oldbiblio->{'authorised_value_images'}  = ($search_context->{'interface'} eq 'opac' && C4::Context->preference('AuthorisedValueImages')) || ($search_context->{'interface'} eq 'intranet' && C4::Context->preference('StaffAuthorisedValueImages')) ? C4::Items::get_authorised_value_images( C4::Biblio::get_biblio_authorised_values( $oldbiblio->{'biblionumber'}, $marcrecord ) ) : [];
Comment 2 Jonathan Druart 2019-04-29 00:05:00 UTC
Well, not really, the method has been removed by
  commit 85e7d186ec2f0a30e479bc924a1023c73eefc28e
  Bug 16167: Remove Authorised value images prefs

But the call has been re-added recently:
  commit 5e4e10c4ca558180137bf5a4ff5a68495efa0ec7
  Bug 14385: Extend OpacHiddenItems to allow specifying exempt borrower categories

So, this bug is fixed, but we have another one running.