Bugzilla – Attachment 131391 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), 2.71 KB, created by
Fridolin Somers
on 2022-03-05 02:03:55 UTC
(
hide
)
Description:
Bug 30232: Logged in user performance for CanUserManageBasket()
Filename:
MIME Type:
Creator:
Fridolin Somers
Created:
2022-03-05 02:03:55 UTC
Size:
2.71 KB
patch
obsolete
>From 7232bc363a58037986146fa40f5e1ca8ac2eb8e6 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(). > >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 | 2 +- > acqui/booksellers.pl | 10 +++------- > 2 files changed, 4 insertions(+), 8 deletions(-) > >diff --git a/acqui/basket.pl b/acqui/basket.pl >index bdc3a4d455..96a04a0f33 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, >diff --git a/acqui/booksellers.pl b/acqui/booksellers.pl >index 51de25d82b..5f9d87be8a 100755 >--- a/acqui/booksellers.pl >+++ b/acqui/booksellers.pl >@@ -96,12 +96,8 @@ 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 $userenv = C4::Context::userenv; > my $viewbaskets = C4::Context->preference('AcqViewBaskets'); >@@ -111,7 +107,7 @@ my $userbranch = $userenv->{branch}; > my $budgets = GetBudgetHierarchy; > my $has_budgets = 0; > foreach my $r (@{$budgets}) { >- next unless (CanUserUseBudget($loggedinuser, $r, $userflags)); >+ next unless (CanUserUseBudget($logged_in_patron->unblessed, $r, $userflags)); > > $has_budgets = 1; > last; >-- >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