Bugzilla – Attachment 116186 Details for
Bug 23830
Koha::AuthorisedValues should use Koha::Objects::Limit::Library
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 23830: Adapt callers
Bug-23830-Adapt-callers.patch (text/plain), 6.12 KB, created by
Martin Renvoize (ashimema)
on 2021-02-02 08:02:29 UTC
(
hide
)
Description:
Bug 23830: Adapt callers
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2021-02-02 08:02:29 UTC
Size:
6.12 KB
patch
obsolete
>From 20eb2760f47f6c678669cb807b982611a837cefe Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Thu, 28 Jan 2021 17:23:45 -0300 >Subject: [PATCH] Bug 23830: Adapt callers > >This patch is the result of making the same changes we did on the >t/db_dependent/AuthorisedValues.t file (replacing the calls to >Koha::AuthorisedValues->search with the tricky branchcode param, and >call ->search_with_library_limits, with the library_id as a third >parameter. > >What I did was: > $ git grep 'Koha::AuthorisedValues\->search' > >and then revisited each of the grep results to check if they added the >'branchcode' parameter to the filters. > >This patch changes the calls to ->search, for >->search_with_library_limits in all the places that require it in the >current codebase [1]. > >To test: >1. Apply this patch >2. Run: > $ kshell > k$ prove t/db_dependent/Koha/Charges/Sales.t \ > t/db_dependent/Ill* >3. Verify the batchmod.pl script is working and filtering the authorised > values keeps working > >[1] Some places like the Koha/Template/Plugin/AuthorisedValues.pm plugin >don't seem to be tested, at first glance. > >Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> >--- > Koha/Charges/Sales.pm | 9 ++++---- > Koha/Illrequest.pm | 27 +++++++++++++++--------- > Koha/Template/Plugin/AuthorisedValues.pm | 6 +++--- > acqui/ajax-getauthvaluedropbox.pl | 6 +++--- > tools/batchMod.pl | 8 ++++++- > 5 files changed, 35 insertions(+), 21 deletions(-) > >diff --git a/Koha/Charges/Sales.pm b/Koha/Charges/Sales.pm >index 71e3d9138d..5d99474868 100644 >--- a/Koha/Charges/Sales.pm >+++ b/Koha/Charges/Sales.pm >@@ -105,11 +105,12 @@ sub _get_valid_payments { > my $self = shift; > > $self->{valid_payments} //= { >- map { $_ => 1 } Koha::AuthorisedValues->search( >+ map { $_ => 1 } Koha::AuthorisedValues->search_with_library_limits( > { >- category => 'PAYMENT_TYPE', >- branchcode => $self->{cash_register}->branch >- } >+ category => 'PAYMENT_TYPE' >+ }, >+ {}, >+ $self->{cash_register}->branch # filter by cash_register branch > )->get_column('authorised_value') > }; > >diff --git a/Koha/Illrequest.pm b/Koha/Illrequest.pm >index 39cf0eabf8..74d9b84d10 100644 >--- a/Koha/Illrequest.pm >+++ b/Koha/Illrequest.pm >@@ -136,11 +136,14 @@ sub statusalias { > # We can't know which result is the right one if there are multiple > # ILLSTATUS authorised values with the same authorised_value column value > # so we just use the first >- return Koha::AuthorisedValues->search({ >- branchcode => $self->branchcode, >- category => 'ILLSTATUS', >- authorised_value => $self->SUPER::status_alias >- })->next; >+ return Koha::AuthorisedValues->search( >+ { >+ category => 'ILLSTATUS', >+ authorised_value => $self->SUPER::status_alias >+ }, >+ {}, >+ $self->branchcode >+ )->next; > } > > =head3 illrequestattributes >@@ -231,11 +234,15 @@ sub status_alias { > # We can't know which result is the right one if there are multiple > # ILLSTATUS authorised values with the same authorised_value column value > # so we just use the first >- my $alias = Koha::AuthorisedValues->search({ >- branchcode => $self->branchcode, >- category => 'ILLSTATUS', >- authorised_value => $self->SUPER::status_alias >- })->next; >+ my $alias = Koha::AuthorisedValues->search( >+ { >+ category => 'ILLSTATUS', >+ authorised_value => $self->SUPER::status_alias >+ }, >+ {}, >+ $self->branchcode >+ )->next; >+ > if ($alias) { > return $alias->authorised_value; > } else { >diff --git a/Koha/Template/Plugin/AuthorisedValues.pm b/Koha/Template/Plugin/AuthorisedValues.pm >index a4e163430a..31d3748f51 100644 >--- a/Koha/Template/Plugin/AuthorisedValues.pm >+++ b/Koha/Template/Plugin/AuthorisedValues.pm >@@ -42,14 +42,14 @@ sub Get { > sub GetAuthValueDropbox { > my ( $self, $category ) = @_; > my $branch_limit = C4::Context->userenv ? C4::Context->userenv->{"branch"} : ""; >- return Koha::AuthorisedValues->search( >+ return Koha::AuthorisedValues->search_with_library_limits( > { >- branchcode => $branch_limit, > category => $category, > }, > { > order_by => [ 'category', 'lib', 'lib_opac' ], >- } >+ }, >+ $branch_limit > ); > } > >diff --git a/acqui/ajax-getauthvaluedropbox.pl b/acqui/ajax-getauthvaluedropbox.pl >index 2693a25042..41c0a8db41 100755 >--- a/acqui/ajax-getauthvaluedropbox.pl >+++ b/acqui/ajax-getauthvaluedropbox.pl >@@ -69,14 +69,14 @@ my $default = $input->param('default'); > $default = C4::Charset::NormalizeString($default); > my $branch_limit = C4::Context->userenv ? C4::Context->userenv->{"branch"} : ""; > >-my $avs = Koha::AuthorisedValues->search( >+my $avs = Koha::AuthorisedValues->search_with_library_limits( > { >- branchcode => $branch_limit, > category => $category, > }, > { > order_by => [ 'category', 'lib', 'lib_opac' ], >- } >+ }, >+ $branch_limit > ); > my $html = qq|<select id="$name" name="$name">|; > while ( my $av = $avs->next ) { >diff --git a/tools/batchMod.pl b/tools/batchMod.pl >index dca2e41ad4..d8bdf97b5f 100755 >--- a/tools/batchMod.pl >+++ b/tools/batchMod.pl >@@ -523,7 +523,13 @@ foreach my $tag (sort keys %{$tagslib}) { > else { > push @authorised_values, ""; # unless ( $tagslib->{$tag}->{$subfield}->{mandatory} ); > >- my @avs = Koha::AuthorisedValues->search({ category => $tagslib->{$tag}->{$subfield}->{authorised_value}, branchcode => $branch_limit },{order_by=>'lib'}); >+ my @avs = Koha::AuthorisedValues->search_with_library_limits( >+ { >+ category => $tagslib->{$tag}->{$subfield}->{authorised_value} >+ }, >+ { order_by => 'lib' }, >+ $branch_limit >+ ); > for my $av ( @avs ) { > push @authorised_values, $av->authorised_value; > $authorised_lib{$av->authorised_value} = $av->lib; >-- >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 23830
:
115989
|
115990
|
116185
| 116186