Bugzilla – Attachment 92697 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.62 KB, created by
Owen Leonard
on 2019-09-10 15:55:22 UTC
(
hide
)
Description:
Bug 23580: Add C4::Context->yaml_preference
Filename:
MIME Type:
Creator:
Owen Leonard
Created:
2019-09-10 15:55:22 UTC
Size:
1.62 KB
patch
obsolete
>From 7e237a4415ae21c87171c94bad6ddb64788a7c40 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 > >Signed-off-by: Owen Leonard <oleonard@myacpl.org> >--- > C4/Context.pm | 21 +++++++++++++++++++++ > 1 file changed, 21 insertions(+) > >diff --git a/C4/Context.pm b/C4/Context.pm >index fa612472f75..54341da5dce 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.11.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