Bug 15344: Remove unucessary call to GetMemberDetails

This subroutine does a lot a processing and should only be called when
necessary.
In the get_template_and_user subroutine (so called from any pages of
Koha), it is call to pass the branchcode, title, firstname, surname and
borrowernumber values for the logged in user.
This subroutine calls GetMemberAccountRecords which retrieve the items
infos for all accountlines entries of the logged in user.
On members/members.pl, let's say you have 74 entries in the accountlines
tables, the page will execute 115 SELECT instead of 35 if you don't have any
accountlines entries.
With this patch, the number of SELECT is always 31.

To test this patch you should have technical skills to know what to do.

Note that USER_INFO was an array of... 1 element. Now it's a hashref.

Signed-off-by: Marc Véron <veron@veron.ch>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
This commit is contained in:
Jonathan Druart 2015-12-09 17:00:10 +00:00 committed by Kyle M Hall
parent 3a7dd6c07c
commit ac541e0fa1
12 changed files with 22 additions and 26 deletions

View File

@ -208,9 +208,10 @@ sub get_template_and_user {
# It's possible for $user to be the borrowernumber if they don't have a
# userid defined (and are logging in through some other method, such
# as SSL certs against an email address)
my $borrower;
$borrowernumber = getborrowernumber($user) if defined($user);
if ( !defined($borrowernumber) && defined($user) ) {
my $borrower = C4::Members::GetMember( borrowernumber => $user );
$borrower = C4::Members::GetMember( borrowernumber => $user );
if ($borrower) {
$borrowernumber = $user;
@ -218,6 +219,8 @@ sub get_template_and_user {
# to do it.
$user = $borrower->{firstname} . ' ' . $borrower->{surname};
}
} else {
$borrower = C4::Members::GetMember( borrowernumber => $borrowernumber );
}
# user info
@ -244,10 +247,7 @@ sub get_template_and_user {
);
}
my ($borr) = C4::Members::GetMemberDetails($borrowernumber);
my @bordat;
$bordat[0] = $borr;
$template->param( "USER_INFO" => \@bordat );
$template->param( "USER_INFO" => $borrower );
my $all_perms = get_all_subpermissions();

View File

@ -88,7 +88,7 @@ if ( $budget_period_id ) {
# ------- get periods stuff ------------------
# USED FOR PERMISSION COMPARISON LATER
my $borrower_id = $template->{VARS}->{'USER_INFO'}[0]->{'borrowernumber'};
my $borrower_id = $template->{VARS}->{'USER_INFO'}->{'borrowernumber'};
my $user = GetMemberDetails($borrower_id);
my $user_branchcode = $user->{'branchcode'};

View File

@ -82,8 +82,8 @@ $template->param(
# ------- get periods stuff ------------------
my $borrower_id = $template->{VARS}->{'USER_INFO'}[0]->{'borrowernumber'};
my $borrower_branchcode = $template->{VARS}->{'USER_INFO'}[0]->{'branchcode'};
my $borrower_id = $template->{VARS}->{'USER_INFO'}->{'borrowernumber'};
my $borrower_branchcode = $template->{VARS}->{'USER_INFO'}->{'branchcode'};
my $periods;
my $authcat = $input->param('authcat');
@ -109,7 +109,7 @@ my $op = $input->param("op");
my $budget_branchcode;
my $budgets_ref = GetBudgetHierarchy( $budget_period_id, $show_mine?$template->{VARS}->{'USER_INFO'}[0]->{'branchcode'}:'', $show_mine?$template->{VARS}->{'USER_INFO'}[0]->{'borrowernumber'}:'' );
my $budgets_ref = GetBudgetHierarchy( $budget_period_id, $show_mine?$template->{VARS}->{'USER_INFO'}->{'branchcode'}:'', $show_mine?$template->{VARS}->{'USER_INFO'}->{'borrowernumber'}:'' );
# build categories list
my $sth = $dbh->prepare("select distinct category from authorised_values where category like 'A%' ");

View File

@ -601,7 +601,7 @@ require( [ 'koha-backend', 'search', 'macros', 'marc-editor', 'marc-record', 'pr
$( sel ).on( event, function (e) {
e.preventDefault();
handler( e, Preferences.user[pref] );
Preferences.Save( [% USER_INFO.0.borrowernumber %] );
Preferences.Save( [% USER_INFO.borrowernumber %] );
showPreference(pref);
} );
}
@ -626,7 +626,7 @@ require( [ 'koha-backend', 'search', 'macros', 'marc-editor', 'marc-record', 'pr
$( document ).on( 'change', 'input.search-toggle-server', function() {
var server_id = $( this ).closest('li').data('server-id');
Preferences.user.selected_search_targets[server_id] = this.checked;
Preferences.Save( [% USER_INFO.0.borrowernumber %] );
Preferences.Save( [% USER_INFO.borrowernumber %] );
} );
break;
}
@ -664,7 +664,7 @@ require( [ 'koha-backend', 'search', 'macros', 'marc-editor', 'marc-record', 'pr
delete Preferences.user.macros[name];
}
Preferences.Save( [% USER_INFO.0.borrowernumber %] );
Preferences.Save( [% USER_INFO.borrowernumber %] );
}
function showSavedMacros( macros ) {
@ -966,7 +966,7 @@ require( [ 'koha-backend', 'search', 'macros', 'marc-editor', 'marc-record', 'pr
$( '#switch-editor' ).click( function() {
if ( !confirm( _("Any changes will not be saved. Continue?") ) ) return;
$.cookie( 'catalogue_editor_[% USER_INFO.0.borrowernumber %]', 'basic', { expires: 365, path: '/' } );
$.cookie( 'catalogue_editor_[% USER_INFO.borrowernumber %]', 'basic', { expires: 365, path: '/' } );
if ( state.backend == 'catalog' ) {
window.location = '/cgi-bin/koha/cataloguing/addbiblio.pl?biblionumber=' + state.recordID;
@ -1072,7 +1072,7 @@ require( [ 'koha-backend', 'search', 'macros', 'marc-editor', 'marc-record', 'pr
} );
// Start editor
Preferences.Load( [% USER_INFO.0.borrowernumber || 0 %] );
Preferences.Load( [% USER_INFO.borrowernumber || 0 %] );
displayPreferences(editor);
makeAuthorisedValueWidgets( '' );
Search.Init( {

View File

@ -111,7 +111,7 @@
if ( !confirm( breedingid ? _("This record cannot be transferred to the advanced editor. Continue?") : _("Any changes will not be saved. Continue?") ) ) return false;
$.cookie( 'catalogue_editor_[% USER_INFO.0.borrowernumber %]', 'advanced', { expires: 365, path: '/' } );
$.cookie( 'catalogue_editor_[% USER_INFO.borrowernumber %]', 'advanced', { expires: 365, path: '/' } );
var biblionumber = [% biblionumber || "null" %];

View File

@ -25,7 +25,7 @@
});
$("#useadvanced").click(function(){
$.cookie( 'catalogue_editor_[% USER_INFO.0.borrowernumber %]', 'advanced', { expires: 365, path: '/' } );
$.cookie( 'catalogue_editor_[% USER_INFO.borrowernumber %]', 'advanced', { expires: 365, path: '/' } );
return true;
});
});

View File

@ -95,7 +95,7 @@
[% END %]
[% END %]
[% IF ( loggedinusername ) %]
<li><p class="members navbar-text">Welcome, <a href="/cgi-bin/koha/opac-user.pl"><span class="loggedinusername">[% FOREACH USER_INF IN USER_INFO %][% USER_INF.title %] [% USER_INF.firstname %] [% USER_INF.surname %][% END %]</span></a></p></li>
<li><p class="members navbar-text">Welcome, <a href="/cgi-bin/koha/opac-user.pl"><span class="loggedinusername">[% USER_INFO.title %] [% USER_INFO.firstname %] [% USER_INFO.surname %]</span></a></p></li>
<li class="divider-vertical"></li>
[% END %]
[% END %]

View File

@ -10,7 +10,7 @@
<ul class="breadcrumb">
<li><a href="/cgi-bin/koha/opac-main.pl">Home</a> <span class="divider">&rsaquo;</span></li>
[% IF ( loggedinusername ) %]
<li><a href="/cgi-bin/koha/opac-user.pl">[% FOREACH USER_INF IN USER_INFO %][% USER_INF.title %] [% USER_INF.firstname %] [% USER_INF.surname %][% END %]</a> <span class="divider">&rsaquo;</span></li>
<li><a href="/cgi-bin/koha/opac-user.pl">[% USER_INFO.title %] [% USER_INFO.firstname %] [% USER_INFO.surname %]</a> <span class="divider">&rsaquo;</span></li>
[% END %]
<li>
[% IF shelf.category == 1 %]

View File

@ -92,11 +92,7 @@
[% UNLESS ( message ) %]
[% UNLESS ( none_available ) %]
<h3>Confirm holds for:
[% FOREACH USER_INF IN USER_INFO %]
[% USER_INF.firstname %] [% USER_INF.surname %] ([% USER_INF.cardnumber %])
[% END %]
</h3>
<h3>Confirm holds for:[% USER_INFO.firstname %] [% USER_INFO.surname %] ([% USER_INFO.cardnumber %])</h3>
[% END # / UNLESS none_available %]
[% IF (RESERVE_CHARGE) %]

View File

@ -11,7 +11,7 @@
<ul class="breadcrumb">
<li><a href="/cgi-bin/koha/opac-main.pl">Home</a> <span class="divider">&rsaquo;</span></li>
[% IF ( loggedinusername ) %]
<li><a href="/cgi-bin/koha/opac-user.pl">[% FOREACH USER_INF IN USER_INFO %][% USER_INF.title %] [% USER_INF.firstname %] [% USER_INF.surname %][% END %]</a> <span class="divider">&rsaquo;</span></li>
<li><a href="/cgi-bin/koha/opac-user.pl">[% USER_INFO.title %] [% USER_INFO.firstname %] [% USER_INFO.surname %]</a> <span class="divider">&rsaquo;</span></li>
[% END %]
<li>Share a list</li>
</ul> <!-- / .breadcrumb -->

View File

@ -42,7 +42,7 @@
<ul class="breadcrumb noprint">
<li><a href="/cgi-bin/koha/opac-main.pl">Home</a> <span class="divider">&rsaquo;</span></li>
[% IF ( loggedinusername ) %]
<li><a href="/cgi-bin/koha/opac-user.pl">[% FOREACH USER_INF IN USER_INFO %][% USER_INF.title %] [% USER_INF.firstname %] [% USER_INF.surname %][% END %]</a> <span class="divider">&rsaquo;</span></li>
<li><a href="/cgi-bin/koha/opac-user.pl">[% USER_INFO.title %] [% USER_INFO.firstname %] [% USER_INFO.surname %]</a> <span class="divider">&rsaquo;</span></li>
[% END %]
[% IF op != 'list' %]

View File

@ -13,7 +13,7 @@
<div class="main">
<ul class="breadcrumb">
<li><a href="/cgi-bin/koha/opac-main.pl">Home</a> <span class="divider">&rsaquo;</span></li>
<li><a href="/cgi-bin/koha/opac-user.pl">[% FOREACH USER_INF IN USER_INFO %][% USER_INF.title %] [% USER_INF.firstname %] [% USER_INF.surname %][% END %]</a> <span class="divider">&rsaquo;</span></li>
<li><a href="/cgi-bin/koha/opac-user.pl">[% USER_INFO.title %] [% USER_INFO.firstname %] [% USER_INFO.surname %]</a> <span class="divider">&rsaquo;</span></li>
<li><a href="#">Your purchase suggestions</a></li>
</ul>