From af49c39cf624bc57406eb7b6ac28c3452d6464b0 Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Sun, 13 May 2018 01:18:01 +0000 Subject: [PATCH] Bug 20760: Correctly fetch authorised values for rancor To test: 1 - Map a marc field to an authorised value in the default framework - say 300$c -> CCODE 2 - Open the advanced cataloguing editor 3 - Create a new field 300$c - note there is no dropdown 4 - browse to: /cgi-bin/koha/svc/cataloguing/framework?callback=define 5 - Note the many instance of Koha::Schema::ResultSet::AuthorisedValueCategory->HASH... 6 - Apply patch 7 - Restart memcached and plack 8 - reload/recreate record in rancor 9 - Note that 300$c is now a dropdown as expected 10 - repeate 4 11 - note the authorised values look correct in response --- svc/cataloguing/framework | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/svc/cataloguing/framework b/svc/cataloguing/framework index 4880b8a..0994fd3 100755 --- a/svc/cataloguing/framework +++ b/svc/cataloguing/framework @@ -9,6 +9,7 @@ use C4::Biblio; use C4::Service; use Koha::Database; use Koha::Libraries; +use Koha::AuthorisedValues; my ( $query, $response ) = C4::Service->init( editcatalogue => 'edit_catalogue' ); @@ -52,18 +53,9 @@ foreach my $class_source (sort keys %$class_sources) { } my $branch_limit = C4::Context->userenv ? C4::Context->userenv->{"branch"} : ""; -my $results; -if( $branch_limit ) { - $results = $schema->resultset( "AuthorisedValue" )->search( - { "authorised_values_branches.branchcode" => { "=", [ $branch_limit, undef ] } }, - { join => "authorised_values_branches", order_by => "lib" } ); -} else { - $results = $schema->resultset( "AuthorisedValue" )->search( - undef, - { order_by => "lib" } ); -} +my $results = Koha::AuthorisedValues->search({ branchcode => $branch_limit },{ order_by => "lib" }); -foreach my $result ( $results->all ) { +while ( my $result = $results->next ) { $authorised_values->{$result->category} ||= []; push @{ $authorised_values->{$result->category} }, { value => $result->authorised_value, lib => $result->lib }; } -- 2.1.4