Bugzilla – Attachment 149236 Details for
Bug 33431
Make code use C4::Context->yaml_preference
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 33431: Make C4::Circulation use C4::Context->yaml_preference
Bug-33431-Make-C4Circulation-use-C4Context-yamlpre.patch (text/plain), 4.13 KB, created by
Tomás Cohen Arazi (tcohen)
on 2023-04-06 14:45:13 UTC
(
hide
)
Description:
Bug 33431: Make C4::Circulation use C4::Context->yaml_preference
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2023-04-06 14:45:13 UTC
Size:
4.13 KB
patch
obsolete
>From c0bba9d6b9e13feddebff83d26c01e957548ec61 Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Thu, 6 Apr 2023 10:48:04 -0300 >Subject: [PATCH] Bug 33431: Make C4::Circulation use > C4::Context->yaml_preference > >This patch removes manual YAML handling for sysprefs in C4::Circulation. > >It also makes C4::Context->yaml_preference not warn when undef is >retrieved from the sysprefs. > >To test: >1. Run: > $ ktd --shell > k$ prove t/db_dependent/Circulation* >=> SUCCESS: Tests pass! >2. Apply this patch >3. Repeat 1 >=> SUCCESS: Tests pass! >4. Sign off :-D >--- > C4/Circulation.pm | 44 +++++++++++++------------------------------- > C4/Context.pm | 2 +- > 2 files changed, 14 insertions(+), 32 deletions(-) > >diff --git a/C4/Circulation.pm b/C4/Circulation.pm >index f1851ed283a..707c2efff5b 100644 >--- a/C4/Circulation.pm >+++ b/C4/Circulation.pm >@@ -21,7 +21,6 @@ package C4::Circulation; > use Modern::Perl; > use DateTime; > use POSIX qw( floor ); >-use YAML::XS; > use Encode; > > use C4::Context; >@@ -1742,21 +1741,12 @@ sub AddIssue { > } > } > >- my $yaml = C4::Context->preference('UpdateNotForLoanStatusOnCheckout'); >- if ($yaml) { >- $yaml = "$yaml\n\n"; >- >- my $rules; >- eval { $rules = YAML::XS::Load(Encode::encode_utf8($yaml)); }; >- if ($@) { >- warn "Unable to parse UpdateNotForLoanStatusOnCheckout syspref : $@"; >- } >- else { >- foreach my $key ( keys %$rules ) { >- if ( $item_object->notforloan eq $key ) { >- $item_object->notforloan($rules->{$key})->store({ log_action => 0, skip_record_index => 1 }); >- last; >- } >+ my $rules = C4::Context->yaml_preference('UpdateNotForLoanStatusOnCheckout'); >+ if ($rules) { >+ foreach my $key ( keys %$rules ) { >+ if ( $item_object->notforloan eq $key ) { >+ $item_object->notforloan($rules->{$key})->store({ log_action => 0, skip_record_index => 1 }); >+ last; > } > } > } >@@ -2164,21 +2154,13 @@ sub AddReturn { > } > } > >- my $yaml = C4::Context->preference('UpdateNotForLoanStatusOnCheckin'); >- if ($yaml) { >- $yaml = "$yaml\n\n"; # YAML is anal on ending \n. Surplus does not hurt >- my $rules; >- eval { $rules = YAML::XS::Load(Encode::encode_utf8($yaml)); }; >- if ($@) { >- warn "Unable to parse UpdateNotForLoanStatusOnCheckin syspref : $@"; >- } >- else { >- foreach my $key ( keys %$rules ) { >- if ( $item->notforloan eq $key ) { >- $messages->{'NotForLoanStatusUpdated'} = { from => $item->notforloan, to => $rules->{$key} }; >- $item->notforloan($rules->{$key})->store({ log_action => 0, skip_record_index => 1, skip_holds_queue => 1 }) unless $rules->{$key} eq 'ONLYMESSAGE'; >- last; >- } >+ my $rules = C4::Context->yaml_preference('UpdateNotForLoanStatusOnCheckin'); >+ if ($rules) { >+ foreach my $key ( keys %$rules ) { >+ if ( $item->notforloan eq $key ) { >+ $messages->{'NotForLoanStatusUpdated'} = { from => $item->notforloan, to => $rules->{$key} }; >+ $item->notforloan($rules->{$key})->store({ log_action => 0, skip_record_index => 1, skip_holds_queue => 1 }) unless $rules->{$key} eq 'ONLYMESSAGE'; >+ last; > } > } > } >diff --git a/C4/Context.pm b/C4/Context.pm >index 3819529dc22..244831e964b 100644 >--- a/C4/Context.pm >+++ b/C4/Context.pm >@@ -342,7 +342,7 @@ the value cannot be properly decoded as YAML. > sub yaml_preference { > my ( $self, $preference ) = @_; > >- my $yaml = eval { YAML::XS::Load( Encode::encode_utf8( $self->preference( $preference ) ) ); }; >+ my $yaml = eval { YAML::XS::Load( Encode::encode_utf8( $self->preference( $preference ) // '' ) ); }; > if ($@) { > warn "Unable to parse $preference syspref : $@"; > return; >-- >2.34.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 33431
:
149236
|
149237
|
149238
|
160245
|
160246
|
160247
|
160281
|
160282
|
160283
|
160392
|
160393
|
160394
|
162381
|
162382
|
162384