Bugzilla – Attachment 45848 Details for
Bug 15344
GetMemberDetails called unecessary
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 15344: Remove unucessary call to GetMemberDetails
Bug-15344-Remove-unucessary-call-to-GetMemberDetai.patch (text/plain), 15.08 KB, created by
Kyle M Hall (khall)
on 2015-12-18 17:21:23 UTC
(
hide
)
Description:
Bug 15344: Remove unucessary call to GetMemberDetails
Filename:
MIME Type:
Creator:
Kyle M Hall (khall)
Created:
2015-12-18 17:21:23 UTC
Size:
15.08 KB
patch
obsolete
>From a73d9236879a5090ad38d87414577cda8a85443a Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Wed, 9 Dec 2015 17:00:10 +0000 >Subject: [PATCH] Bug 15344: Remove unucessary call to GetMemberDetails >MIME-Version: 1.0 >Content-Type: text/plain; charset=UTF-8 >Content-Transfer-Encoding: 8bit > >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> >--- > C4/Auth.pm | 10 +++++----- > admin/aqbudgets.pl | 2 +- > admin/aqplan.pl | 6 +++--- > koha-tmpl/intranet-tmpl/prog/en/includes/cateditor-ui.inc | 10 +++++----- > .../intranet-tmpl/prog/en/modules/cataloguing/addbiblio.tt | 2 +- > .../intranet-tmpl/prog/en/modules/cataloguing/addbooks.tt | 2 +- > koha-tmpl/opac-tmpl/bootstrap/en/includes/masthead.inc | 2 +- > .../opac-tmpl/bootstrap/en/modules/opac-downloadshelf.tt | 2 +- > koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-reserve.tt | 6 +----- > koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-shareshelf.tt | 2 +- > koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-shelves.tt | 2 +- > koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-suggestions.tt | 2 +- > 12 files changed, 22 insertions(+), 26 deletions(-) > >diff --git a/C4/Auth.pm b/C4/Auth.pm >index 8512fd9..3d5aba3 100644 >--- a/C4/Auth.pm >+++ b/C4/Auth.pm >@@ -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(); > >diff --git a/admin/aqbudgets.pl b/admin/aqbudgets.pl >index 2d85fdc..d78ba12 100755 >--- a/admin/aqbudgets.pl >+++ b/admin/aqbudgets.pl >@@ -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'}; > >diff --git a/admin/aqplan.pl b/admin/aqplan.pl >index d0b11a2..f1bf496 100755 >--- a/admin/aqplan.pl >+++ b/admin/aqplan.pl >@@ -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%' "); >diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/cateditor-ui.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/cateditor-ui.inc >index 443c022..6ffaf62 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/cateditor-ui.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/cateditor-ui.inc >@@ -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( { >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbiblio.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbiblio.tt >index 542d8cb..2b6b327 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbiblio.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbiblio.tt >@@ -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" %]; > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbooks.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbooks.tt >index 9ef3543..290b386 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbooks.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbooks.tt >@@ -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; > }); > }); >diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/includes/masthead.inc b/koha-tmpl/opac-tmpl/bootstrap/en/includes/masthead.inc >index 20ff3f8..5a2e011 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/en/includes/masthead.inc >+++ b/koha-tmpl/opac-tmpl/bootstrap/en/includes/masthead.inc >@@ -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 %] >diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-downloadshelf.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-downloadshelf.tt >index ee0f205..4e4f832 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-downloadshelf.tt >+++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-downloadshelf.tt >@@ -10,7 +10,7 @@ > <ul class="breadcrumb"> > <li><a href="/cgi-bin/koha/opac-main.pl">Home</a> <span class="divider">›</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">›</span></li> >+ <li><a href="/cgi-bin/koha/opac-user.pl">[% USER_INFO.title %] [% USER_INFO.firstname %] [% USER_INFO.surname %]</a> <span class="divider">›</span></li> > [% END %] > <li> > [% IF shelf.category == 1 %] >diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-reserve.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-reserve.tt >index a864dde..ca35f76 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-reserve.tt >+++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-reserve.tt >@@ -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) %] >diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-shareshelf.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-shareshelf.tt >index 22670b9..8a9de13 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-shareshelf.tt >+++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-shareshelf.tt >@@ -11,7 +11,7 @@ > <ul class="breadcrumb"> > <li><a href="/cgi-bin/koha/opac-main.pl">Home</a> <span class="divider">›</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">›</span></li> >+ <li><a href="/cgi-bin/koha/opac-user.pl">[% USER_INFO.title %] [% USER_INFO.firstname %] [% USER_INFO.surname %]</a> <span class="divider">›</span></li> > [% END %] > <li>Share a list</li> > </ul> <!-- / .breadcrumb --> >diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-shelves.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-shelves.tt >index 3c96dde..a92a5cb 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-shelves.tt >+++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-shelves.tt >@@ -42,7 +42,7 @@ > <ul class="breadcrumb noprint"> > <li><a href="/cgi-bin/koha/opac-main.pl">Home</a> <span class="divider">›</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">›</span></li> >+ <li><a href="/cgi-bin/koha/opac-user.pl">[% USER_INFO.title %] [% USER_INFO.firstname %] [% USER_INFO.surname %]</a> <span class="divider">›</span></li> > [% END %] > > [% IF op != 'list' %] >diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-suggestions.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-suggestions.tt >index 78d18fc..c176a12 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-suggestions.tt >+++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-suggestions.tt >@@ -13,7 +13,7 @@ > <div class="main"> > <ul class="breadcrumb"> > <li><a href="/cgi-bin/koha/opac-main.pl">Home</a> <span class="divider">›</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">›</span></li> >+ <li><a href="/cgi-bin/koha/opac-user.pl">[% USER_INFO.title %] [% USER_INFO.firstname %] [% USER_INFO.surname %]</a> <span class="divider">›</span></li> > <li><a href="#">Your purchase suggestions</a></li> > </ul> > >-- >1.7.10.4
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 15344
:
45553
|
45560
|
45604
|
45605
| 45848 |
45849
|
46121
|
46129