Bugzilla – Attachment 92708 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.66 KB, created by
Marcel de Rooy
on 2019-09-11 11:24:12 UTC
(
hide
)
Description:
Bug 23580: Add C4::Context->yaml_preference
Filename:
MIME Type:
Creator:
Marcel de Rooy
Created:
2019-09-11 11:24:12 UTC
Size:
1.66 KB
patch
obsolete
>From 8b0fbe72f3c1df7930227f5a923ab72c4f3b25f7 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 >Content-Type: text/plain; charset=utf-8 > >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: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >--- > 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.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