Bugzilla – Attachment 110167 Details for
Bug 24786
Allow setting a cash register for a login session and configuring library-default cash registers
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 24786: (follow-up) Cache the register_name in the session
Bug-24786-follow-up-Cache-the-registername-in-the-.patch (text/plain), 9.56 KB, created by
Martin Renvoize (ashimema)
on 2020-09-16 10:27:14 UTC
(
hide
)
Description:
Bug 24786: (follow-up) Cache the register_name in the session
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2020-09-16 10:27:14 UTC
Size:
9.56 KB
patch
obsolete
>From fae6f1f353bee545800a5940958d8eaa52be2600 Mon Sep 17 00:00:00 2001 >From: Martin Renvoize <martin.renvoize@ptfs-europe.com> >Date: Tue, 4 Aug 2020 13:27:06 +0100 >Subject: [PATCH] Bug 24786: (follow-up) Cache the register_name in the session > >This leads to one DB hit less per page load in the staff client when >cash registers are enabled. >--- > C4/Auth.pm | 16 ++++++++------ > C4/Context.pm | 21 ++++++++++--------- > Koha/Template/Plugin/Registers.pm | 5 +++-- > circ/set-library.pl | 6 +++--- > .../prog/en/modules/circ/set-library.tt | 4 ++-- > 5 files changed, 29 insertions(+), 23 deletions(-) > >diff --git a/C4/Auth.pm b/C4/Auth.pm >index a1acf805c6..8dcee3fc0e 100644 >--- a/C4/Auth.pm >+++ b/C4/Auth.pm >@@ -38,6 +38,7 @@ use Koha::Checkouts; > use Koha::DateUtils qw(dt_from_string); > use Koha::Library::Groups; > use Koha::Libraries; >+use Koha::Cash::Registers; > use Koha::Desks; > use Koha::Patrons; > use Koha::Patron::Consents; >@@ -858,7 +859,7 @@ sub checkauth { > $session->param('branchname'), $session->param('flags'), > $session->param('emailaddress'), $session->param('shibboleth'), > $session->param('desk_id'), $session->param('desk_name'), >- $session->param('register_id') >+ $session->param('register_id'), $session->param('register_name') > ); > C4::Context::set_shelves_userenv( 'bar', $session->param('barshelves') ); > C4::Context::set_shelves_userenv( 'pub', $session->param('pubshelves') ); >@@ -1081,7 +1082,7 @@ sub checkauth { > } > my ( $borrowernumber, $firstname, $surname, $userflags, > $branchcode, $branchname, $emailaddress, $desk_id, >- $desk_name, $register_id ); >+ $desk_name, $register_id, $register_name ); > > if ( $return == 1 ) { > my $select = " >@@ -1132,6 +1133,8 @@ sub checkauth { > } > if ( $query->param('register_id') ) { > $register_id = $query->param('register_id'); >+ my $register = Koha::Cash::Registers->find($register_id); >+ $register_name = $register ? $register->name : ''; > } > my $branches = { map { $_->branchcode => $_->unblessed } Koha::Libraries->search }; > if ( $type ne 'opac' and C4::Context->boolean_preference('AutoLocation') ) { >@@ -1178,6 +1181,7 @@ sub checkauth { > $session->param( 'interface', $type); > $session->param( 'shibboleth', $shibSuccess ); > $session->param( 'register_id', $register_id ); >+ $session->param( 'register_name', $register_name ); > $debug and printf STDERR "AUTH_4: (%s)\t%s %s - %s\n", map { $session->param($_) } qw(cardnumber firstname surname branch); > } > $session->param('cas_ticket', $cas_ticket) if $cas_ticket; >@@ -1188,7 +1192,7 @@ sub checkauth { > $session->param('branchname'), $session->param('flags'), > $session->param('emailaddress'), $session->param('shibboleth'), > $session->param('desk_id'), $session->param('desk_name'), >- $session->param('register_id') >+ $session->param('register_id'), $session->param('register_name') > ); > > } >@@ -1468,7 +1472,7 @@ sub check_api_auth { > $session->param('branchname'), $session->param('flags'), > $session->param('emailaddress'), $session->param('shibboleth'), > $session->param('desk_id'), $session->param('desk_name'), >- $session->param('register_id') >+ $session->param('register_id'), $session->param('register_name') > ); > > my $ip = $session->param('ip'); >@@ -1632,7 +1636,7 @@ sub check_api_auth { > $session->param('branchname'), $session->param('flags'), > $session->param('emailaddress'), $session->param('shibboleth'), > $session->param('desk_id'), $session->param('desk_name'), >- $session->param('register_id') >+ $session->param('register_id'), $session->param('register_name') > ); > return ( "ok", $cookie, $sessionID ); > } else { >@@ -1722,7 +1726,7 @@ sub check_cookie_auth { > $session->param('branchname'), $session->param('flags'), > $session->param('emailaddress'), $session->param('shibboleth'), > $session->param('desk_id'), $session->param('desk_name'), >- $session->param('register_id') >+ $session->param('register_id'), $session->param('register_name') > ); > > my $ip = $session->param('ip'); >diff --git a/C4/Context.pm b/C4/Context.pm >index 8af83eb2e6..774d4b5257 100644 >--- a/C4/Context.pm >+++ b/C4/Context.pm >@@ -809,7 +809,7 @@ sub userenv { > $userbranch, $branchname, $userflags, > $emailaddress, $shibboleth > $desk_id, $desk_name, >- $register_id); >+ $register_id, $register_name); > > Establish a hash of user environment variables. > >@@ -820,7 +820,7 @@ set_userenv is called in Auth.pm > #' > sub set_userenv { > shift @_; >- my ($usernum, $userid, $usercnum, $userfirstname, $usersurname, $userbranch, $branchname, $userflags, $emailaddress, $shibboleth, $desk_id, $desk_name, $register_id)= >+ my ($usernum, $userid, $usercnum, $userfirstname, $usersurname, $userbranch, $branchname, $userflags, $emailaddress, $shibboleth, $desk_id, $desk_name, $register_id, $register_name)= > map { Encode::is_utf8( $_ ) ? $_ : Encode::decode('UTF-8', $_) } # CGI::Session doesn't handle utf-8, so we decode it here > @_; > my $var=$context->{"activeuser"} || ''; >@@ -832,14 +832,15 @@ sub set_userenv { > "surname" => $usersurname, > > #possibly a law problem >- "branch" => $userbranch, >- "branchname" => $branchname, >- "flags" => $userflags, >- "emailaddress" => $emailaddress, >- "shibboleth" => $shibboleth, >- "desk_id" => $desk_id, >- "desk_name" => $desk_name, >- "register_id" => $register_id, >+ "branch" => $userbranch, >+ "branchname" => $branchname, >+ "flags" => $userflags, >+ "emailaddress" => $emailaddress, >+ "shibboleth" => $shibboleth, >+ "desk_id" => $desk_id, >+ "desk_name" => $desk_name, >+ "register_id" => $register_id, >+ "register_name" => $register_name > }; > $context->{userenv}->{$var} = $cell; > return $cell; >diff --git a/Koha/Template/Plugin/Registers.pm b/Koha/Template/Plugin/Registers.pm >index ea38dff1eb..d68c834e0a 100644 >--- a/Koha/Template/Plugin/Registers.pm >+++ b/Koha/Template/Plugin/Registers.pm >@@ -37,8 +37,9 @@ sub session_register_id { > sub session_register_name { > my ($self) = @_; > >- my $register = Koha::Cash::Registers->find($self->session_register_id); >- return $register ? $register->name : ''; >+ return C4::Context->userenv >+ ? C4::Context->userenv->{'register_name'} >+ : ''; > } > > =head2 >diff --git a/circ/set-library.pl b/circ/set-library.pl >index 4e7b7be128..b460b15466 100755 >--- a/circ/set-library.pl >+++ b/circ/set-library.pl >@@ -81,14 +81,14 @@ if ( $branch and my $library = Koha::Libraries->find($branch) ) { > if ( defined($userenv_register_id) > && ( $userenv_register_id ne $register_id ) ) > { >+ my $old_register_name = C4::Context->userenv->{'register_name'} || ''; > my $register = Koha::Cash::Registers->find($register_id); >- $template->param(LoginRegisterID => $register_id); # update template for new register >- $template->param(LoginRegisterName => $register ? $register->name : ''); # update template for new register > $session->param( 'register_id', $register_id ); >+ $session->param( 'register_name', $register ? $register->name : '' ); > push @updated, > { > updated_register => 1, >- new_register => $register ? $register->name : '' >+ old_register => $old_register_name > }; > } > $session->flush(); >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/set-library.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/set-library.tt >index 49db4c3da7..be0003b93d 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/set-library.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/set-library.tt >@@ -45,14 +45,14 @@ > Updated:<ul> > [% FOREACH update IN updated %] > [% IF ( update.updated_branch || update.updated_desk || update.updated_register ) %] >- [% IF ( updated.updated.branch ) %] >+ [% IF ( updated.updated_branch ) %] > <li>Library: [% update.old_branch or "?" | html %] ⇒ [% update.new_branch or "?" | html %]</li> > [% END %] > [% IF ( update.updated_desk ) %] > <li>Desk: [% update.old_desk or "?" | html %] ⇒ [% LoginDeskname or "?" | html %]</li> > [% END %] > [% IF ( updated.updated_register ) %] >- <li>Register: [% updated.new_register | html %]</li> >+ <li>Register: [% updated.old_register or "?" | html %] ⇒ [% Registers.session_register_name or "?" | html %]</li> > [% END %] > [% ELSE %] > <li>ERROR - unknown</li> >-- >2.20.1
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 24786
:
107145
|
107146
|
107147
|
107148
|
107149
|
107739
|
107740
|
107741
|
107742
|
107743
|
107754
|
107755
|
107756
|
107757
|
107758
|
107759
|
107957
|
107958
|
107959
|
107960
|
107961
|
107962
|
108060
|
108061
|
108062
|
108063
|
108064
|
108065
|
108066
|
108510
|
108511
|
108512
|
108513
|
108514
|
108515
|
108516
|
110162
|
110163
|
110164
|
110165
|
110166
|
110167
|
110168
|
110187
|
110188
|
110189
|
110190
|
110191
|
110192
|
110193
|
111066
|
111067
|
111068
|
111069
|
111070
|
111071
|
111072
|
111074
|
111126
|
111127
|
111128
|
111129
|
111130
|
111131
|
111132
|
111133
|
111220
|
111221
|
111222
|
111223
|
111224
|
111225
|
111226
|
111227
|
111228
|
111229
|
111230
|
111231
|
111232
|
111233
|
111234
|
111235
|
111611
|
111612
|
111613
|
111614
|
111615
|
111616
|
111617
|
111618
|
111619
|
111620
|
111623
|
111725
|
111757
|
111758
|
111759
|
111760
|
111761
|
111762
|
111763
|
111764
|
111765
|
111766
|
111767
|
111768
|
111769
|
111770
|
111776
|
111777
|
111778
|
111779
|
111780
|
111781
|
111782
|
111783
|
111784
|
111785
|
111786
|
111787
|
111788
|
112985
|
112988
|
112989
|
113226
|
113227
|
113241
|
113251
|
113253
|
113256
|
113257
|
113260