From f14963605924eacbbaf965c600c65401288b6f2f Mon Sep 17 00:00:00 2001 From: Fridolin Somers Date: Tue, 17 Mar 2015 14:50:14 +0100 Subject: [PATCH] Bug 13852 - Manage C4::VirtualShelves in C4::Auth for performance In C4::Auth there is a use C4::VirtualShelves. Virtualshelves are displayed in all OPAC pages, but not in intranet. For performance, we should move this into a require only for opac pages. This patch adds a condition to fetch virtualshelves only if opac and moves the dependancy on C4::VirtualShelves into require calls. On my desktop, I have those compilation times for C4/Auth.pm : - Without patch : 0,41 seconds - With patch : 0,22 seconds This performance improvement is very usefull for pages that only use a few as dependancy, like errors/404.pl Test plan : - Be sure there are some public lists - Apply patch - Go to opac (not logged-in) - Click on "Lists" - Check you see the public lists - Login with a user - Be sure this user has some private lists - Click on "Lists" - Check you see the public and private lists - Logout - Go to /cgi-bin/koha/opac-reserve.pl - You see the loggin page - Click on "Lists" - Check you see the public lists - Go to intranet - Check you can loggin Signed-off-by: Marcel de Rooy Signed-off-by: Kyle M Hall Signed-off-by: Tomas Cohen Arazi --- C4/Auth.pm | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/C4/Auth.pm b/C4/Auth.pm index 6bdab57b72..3767b2297c 100644 --- a/C4/Auth.pm +++ b/C4/Auth.pm @@ -30,7 +30,6 @@ use C4::Templates; # to get the template use C4::Languages; use C4::Branch; # GetBranches use C4::Search::History; -use C4::VirtualShelves; use Koha::AuthUtils qw(hash_password); use POSIX qw/strftime/; use List::MoreUtils qw/ any /; @@ -199,13 +198,16 @@ sub get_template_and_user { $template->param( loggedinusernumber => $borrowernumber ); $template->param( sessionID => $sessionID ); - my ( $total, $pubshelves, $barshelves ) = C4::VirtualShelves::GetSomeShelfNames( $borrowernumber, 'MASTHEAD' ); - $template->param( - pubshelves => $total->{pubtotal}, - pubshelvesloop => $pubshelves, - barshelves => $total->{bartotal}, - barshelvesloop => $barshelves, - ); + if ( $in->{'type'} eq 'opac' ) { + require C4::VirtualShelves; + my ( $total, $pubshelves, $barshelves ) = C4::VirtualShelves::GetSomeShelfNames( $borrowernumber, 'MASTHEAD' ); + $template->param( + pubshelves => $total->{pubtotal}, + pubshelvesloop => $pubshelves, + barshelves => $total->{bartotal}, + barshelvesloop => $barshelves, + ); + } my ($borr) = C4::Members::GetMemberDetails($borrowernumber); my @bordat; @@ -334,11 +336,14 @@ sub get_template_and_user { $template->param( sessionID => $sessionID ); - my ( $total, $pubshelves ) = C4::VirtualShelves::GetSomeShelfNames( undef, 'MASTHEAD' ); - $template->param( - pubshelves => $total->{pubtotal}, - pubshelvesloop => $pubshelves, - ); + if ( $in->{'type'} eq 'opac' ){ + require C4::VirtualShelves; + my ( $total, $pubshelves ) = C4::VirtualShelves::GetSomeShelfNames( undef, 'MASTHEAD' ); + $template->param( + pubshelves => $total->{pubtotal}, + pubshelvesloop => $pubshelves, + ); + } } # Anonymous opac search history @@ -1202,6 +1207,7 @@ sub checkauth { $template->param( loginprompt => 1 ) unless $info{'nopermission'}; if ( $type eq 'opac' ) { + require C4::VirtualShelves; my ( $total, $pubshelves ) = C4::VirtualShelves::GetSomeShelfNames( undef, 'MASTHEAD' ); $template->param( pubshelves => $total->{pubtotal}, -- 2.39.5