Bugzilla – Attachment 92691 Details for
Bug 23580
Add C4::Context->yaml_preference
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 23580: Add C4::Context->yaml_preference
Bug-23580-Add-C4Context-yamlpreference.patch (text/plain), 1.56 KB, created by
Tomás Cohen Arazi (tcohen)
on 2019-09-10 14:49:20 UTC
(
hide
)
Description:
Bug 23580: Add C4::Context->yaml_preference
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2019-09-10 14:49:20 UTC
Size:
1.56 KB
patch
obsolete
>From bf389f31d90c91e48df5a42fddc4b9256481121f Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Tue, 10 Sep 2019 11:42:31 -0300 >Subject: [PATCH] Bug 23580: Add C4::Context->yaml_preference > >This patch adds a new methods to be used on YAML-based sysprefs. The >idea is that we would use it instead of handling the YAML decoding >in-place everywhere we use YAML syprefs. > >Ideally, we could even move pipe separated values sysprefs into YAML, >etc. > >To test: >- Apply this patches >- Run: > $ kshell > k$ prove t/Context.t >=> SUCCESS: Tests pass! >- Sign off :-D >--- > C4/Context.pm | 21 +++++++++++++++++++++ > 1 file changed, 21 insertions(+) > >diff --git a/C4/Context.pm b/C4/Context.pm >index fa612472f7..54341da5dc 100644 >--- a/C4/Context.pm >+++ b/C4/Context.pm >@@ -96,6 +96,7 @@ use Encode; > use File::Spec; > use Module::Load::Conditional qw(can_load); > use POSIX (); >+use YAML qw/Load/; > use ZOOM; > > use C4::Boolean; >@@ -437,6 +438,26 @@ sub boolean_preference { > return defined($it)? C4::Boolean::true_p($it): undef; > } > >+=head2 yaml_preference >+ >+Retrieves the required system preference value, and converts it >+from YAML into a Perl data structure. It throws an exception if >+the value cannot be properly decoded as YAML. >+ >+=cut >+ >+sub yaml_preference { >+ my ( $self, $preference ) = @_; >+ >+ my $yaml = eval { YAML::Load( $self->preference( $preference ) ); }; >+ if ($@) { >+ warn "Unable to parse $preference syspref : $@"; >+ return; >+ } >+ >+ return $yaml; >+} >+ > =head2 enable_syspref_cache > > C4::Context->enable_syspref_cache(); >-- >2.23.0
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 23580
:
92690
|
92691
|
92696
|
92697
|
92707
|
92708