Bugzilla – Attachment 131395 Details for
Bug 30232
Acquisition logged in user performance
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 30232: Logged in user performance for CanUserManageBasket()
Bug-30232-Logged-in-user-performance-for-CanUserMa.patch (text/plain), 3.59 KB, created by
Fridolin Somers
on 2022-03-05 06:21:56 UTC
(
hide
)
Description:
Bug 30232: Logged in user performance for CanUserManageBasket()
Filename:
MIME Type:
Creator:
Fridolin Somers
Created:
2022-03-05 06:21:56 UTC
Size:
3.59 KB
patch
obsolete
>From 0484a4834983daed853869d0dbb48fe34524c55e Mon Sep 17 00:00:00 2001 >From: Fridolin Somers <fridolin.somers@biblibre.com> >Date: Fri, 4 Mar 2022 15:10:00 -1000 >Subject: [PATCH] Bug 30232: Logged in user performance for > CanUserManageBasket() > >Some acquisition methods can take borrowernumber or a Koha::Patron->unblessed. >When called with logged in user, sometimes in a loop, performance will be better if fetching Koha::Patron of logged in user only once. > >This patch optimises call for CanUserManageBasket(). >Also removes a useless refetch of logged in patron. > >You may benchmark on a vendor with a lot of baskets. > >Test plan >1) >1.1) Log in to staff interface as user A with all acquisition permissions >1.2) Set system preference 'AcqViewBaskets' to 'created or managed by staff member' >1.3) Create a new basket >1.4) Copy URL, ie /cgi-bin/koha/acqui/basket.pl?basketno=2 >1.5) Click on 'Baskets' tab, you see the basket in table >2) >2.1) Log in to staff interface as user B with acquisition permissions > but not 'order_manage_all' >2.2) Go to URL => You don't have access to basket >2.3) Click on 'Baskets' tab => you don't see the basket in table >--- > acqui/basket.pl | 5 ++--- > acqui/booksellers.pl | 11 ++++------- > 2 files changed, 6 insertions(+), 10 deletions(-) > >diff --git a/acqui/basket.pl b/acqui/basket.pl >index bdc3a4d455..0710861946 100755 >--- a/acqui/basket.pl >+++ b/acqui/basket.pl >@@ -95,7 +95,7 @@ my $rs = $schema->resultset('VendorEdiAccount')->search( > { vendor_id => $booksellerid, } ); > $template->param( ediaccount => ($rs->count > 0)); > >-unless (CanUserManageBasket($loggedinuser, $basket, $userflags)) { >+unless (CanUserManageBasket($logged_in_patron->unblessed, $basket, $userflags)) { > $template->param( > cannot_manage_basket => 1, > basketno => $basketno, >@@ -287,8 +287,7 @@ if ( $op eq 'list' ) { > > #if the basket is closed,and the user has the permission to edit basketgroups, display a list of basketgroups > my ($basketgroup, $basketgroups); >- my $patron = Koha::Patrons->find($loggedinuser); >- if ($basket->{closedate} && haspermission($patron->userid, { acquisition => 'group_manage'} )) { >+ if ($basket->{closedate} && haspermission($logged_in_patron->userid, { acquisition => 'group_manage'} )) { > $basketgroups = GetBasketgroups($basket->{booksellerid}); > for my $bg ( @{$basketgroups} ) { > if ($basket->{basketgroupid} && $basket->{basketgroupid} == $bg->{id}){ >diff --git a/acqui/booksellers.pl b/acqui/booksellers.pl >index 51de25d82b..959f829d48 100755 >--- a/acqui/booksellers.pl >+++ b/acqui/booksellers.pl >@@ -96,12 +96,9 @@ if ( $supplier_count == 1 ) { > ); > } > >-my $uid; >-# FIXME This script should only be accessed by a valid logged in patron >-if ($loggedinuser) { >- # FIXME Should not be needed, logged in patron should be cached >- $uid = Koha::Patrons->find( $loggedinuser )->userid; >-} >+# FIXME Should not be needed, logged in patron should be cached >+my $logged_in_patron = Koha::Patrons->find($loggedinuser); >+my $logged_in_patron_unblessed = $logged_in_patron->unblessed; > > my $userenv = C4::Context::userenv; > my $viewbaskets = C4::Context->preference('AcqViewBaskets'); >@@ -126,7 +123,7 @@ for my $vendor (@suppliers) { > my $loop_basket = []; > > for my $basket ( @{$baskets} ) { >- if (CanUserManageBasket($loggedinuser, $basket, $userflags)) { >+ if (CanUserManageBasket($logged_in_patron_unblessed, $basket, $userflags)) { > my $patron = Koha::Patrons->find( $basket->{authorisedby} ); > foreach (qw(total_items total_biblios expected_items)) { > $basket->{$_} ||= 0; >-- >2.35.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 30232
:
131391
|
131392
|
131393
| 131395 |
131396