From a4ad43724c0e75abc27cb536b8b0c3ccb1761bba Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Thu, 6 Apr 2023 11:27:14 -0300 Subject: [PATCH] Bug 33431: Fix remaining cases This patch tweaks three remaining cases, that are not covered by tests. To test: 1. Apply this patch 2. Make use of those places => SUCCESS: No behavior change Signed-off-by: David Nind Signed-off-by: Pedro Amorim Signed-off-by: Katrin Fischer --- C4/Ris.pm | 12 +----------- acqui/addorderiso2709.pl | 12 ++---------- circ/pendingreserves.pl | 26 +++++++++----------------- 3 files changed, 12 insertions(+), 38 deletions(-) diff --git a/C4/Ris.pm b/C4/Ris.pm index cf30a40b62..b03f1eaa70 100644 --- a/C4/Ris.pm +++ b/C4/Ris.pm @@ -63,7 +63,6 @@ package C4::Ris; use Modern::Perl; use List::MoreUtils qw( uniq ); -use YAML::XS; use Encode; use vars qw(@ISA @EXPORT); @@ -117,16 +116,7 @@ sub marc2ris { ## else: other MARC formats do not specify the character encoding ## we assume it's *not* UTF-8 - my $RisExportAdditionalFields = C4::Context->preference('RisExportAdditionalFields'); - my $ris_additional_fields; - if ($RisExportAdditionalFields) { - $RisExportAdditionalFields = "$RisExportAdditionalFields\n\n"; - $ris_additional_fields = eval { YAML::XS::Load(Encode::encode_utf8($RisExportAdditionalFields)); }; - if ($@) { - warn "Unable to parse RisExportAdditionalFields : $@"; - $ris_additional_fields = undef; - } - } + my $ris_additional_fields = C4::Context->yaml_preference('RisExportAdditionalFields'); ## start RIS dataset if ( $ris_additional_fields && $ris_additional_fields->{TY} ) { diff --git a/acqui/addorderiso2709.pl b/acqui/addorderiso2709.pl index 86b79fa54c..d9b2725b65 100755 --- a/acqui/addorderiso2709.pl +++ b/acqui/addorderiso2709.pl @@ -23,7 +23,6 @@ use Modern::Perl; use CGI qw ( -utf8 ); -use YAML::XS; use List::MoreUtils; use Encode; use Scalar::Util qw( looks_like_number ); @@ -645,15 +644,8 @@ sub add_matcher_list { sub get_infos_syspref { my ($syspref_name, $record, $field_list) = @_; - my $syspref = C4::Context->preference($syspref_name); - $syspref = "$syspref\n\n"; # YAML is anal on ending \n. Surplus does not hurt - my $yaml = eval { - YAML::XS::Load(Encode::encode_utf8($syspref)); - }; - if ( $@ ) { - warn "Unable to parse $syspref syspref : $@"; - return (); - } + my $yaml = C4::Context->yaml_preference($syspref_name); + my $r; for my $field_name ( @$field_list ) { next unless exists $yaml->{$field_name}; diff --git a/circ/pendingreserves.pl b/circ/pendingreserves.pl index 58b956038a..11182e12b1 100755 --- a/circ/pendingreserves.pl +++ b/circ/pendingreserves.pl @@ -21,7 +21,6 @@ use Modern::Perl; use constant PULL_INTERVAL => 2; use List::MoreUtils qw( uniq ); -use YAML::XS; use Encode; use C4::Context; @@ -106,22 +105,15 @@ if ( $op eq 'cud-cancel_reserve' and $reserve_id ) { C4::Items::ModItemTransfer( $item->itemnumber, $item->holdingbranch, $item->homebranch, 'LostReserve' ); } - if ( my $yaml = C4::Context->preference('UpdateItemWhenLostFromHoldList') ) { - $yaml = "$yaml\n\n"; # YAML is anal on ending \n. Surplus does not hurt - my $assignments; - eval { $assignments = YAML::XS::Load(Encode::encode_utf8($yaml)); }; - if ($@) { - warn "Unable to parse UpdateItemWhenLostFromHoldList syspref : $@" if $@; - } - else { - eval { - while ( my ( $f, $v ) = each( %$assignments ) ) { - $item->$f($v); - } - $item->store; - }; - warn "Unable to modify item itemnumber=" . $item->itemnumber . ": $@" if $@; - } + my $assignments = C4::Context->yaml_preference('UpdateItemWhenLostFromHoldList'); + if ( $assignments ) { + eval { + while ( my ( $f, $v ) = each( %$assignments ) ) { + $item->$f($v); + } + $item->store; + }; + warn "Unable to modify item itemnumber=" . $item->itemnumber . ": $@" if $@; } } elsif ( not $item ) { -- 2.39.5