Bugzilla – Attachment 151732 Details for
Bug 32478
Remove Koha::Config::SysPref->find since bypasses cache
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 32478: (QA follow-up) Keep current hashref behavior
Bug-32478-QA-follow-up-Keep-current-hashref-behavi.patch (text/plain), 2.48 KB, created by
Marcel de Rooy
on 2023-05-26 10:07:35 UTC
(
hide
)
Description:
Bug 32478: (QA follow-up) Keep current hashref behavior
Filename:
MIME Type:
Creator:
Marcel de Rooy
Created:
2023-05-26 10:07:35 UTC
Size:
2.48 KB
patch
obsolete
>From 6e11224ba32d35ef7e663f669e2bd602b4bb71e8 Mon Sep 17 00:00:00 2001 >From: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >Date: Fri, 26 May 2023 09:28:28 +0000 >Subject: [PATCH] Bug 32478: (QA follow-up) Keep current hashref behavior >Content-Type: text/plain; charset=utf-8 > >Prevent a crash on wrong contents for ItemsDeniedRenewal pref >as we did before. >Note: Could be a provisional measure (no band aid to repeat anywhere) >until we resolve this in preferences.pl. > >Test plan: >Without this patch: >Change ItemsDeniedRenewal to 'nonsense' >Run perl -MKoha::Items -e'Koha::Items->find(X)->is_denied_renewal; print "OK\n"' >=> Replace X by a valid itemnumber >Crashes with: Can't use string ("nonsense") as a HASH ref ... No OK print. > >Apply this patch >Run perl -MKoha::Items -e'Koha::Items->find(X)->is_denied_renewal; print "OK\n"' >=> Replace X by a valid itemnumber >Warns only with: Hashref expected for ItemsDeniedRenewal. You got OK. >Clear ItemsDeniedRenewal >Try again. No warning anymore. >Run t/Context.t > >Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >--- > C4/Context.pm | 2 ++ > t/Context.t | 8 +++++++- > 2 files changed, 9 insertions(+), 1 deletion(-) > >diff --git a/C4/Context.pm b/C4/Context.pm >index 35c5025745..6406f340ec 100644 >--- a/C4/Context.pm >+++ b/C4/Context.pm >@@ -348,6 +348,8 @@ sub yaml_preference { > return; > } > >+ # TODO Remove next line when enforced elsewhere >+ if( $yaml && lc($preference) eq 'itemsdeniedrenewal' and ref($yaml) ne 'HASH' ) { warn "Hashref expected for $preference"; return; } > return $yaml; > } > >diff --git a/t/Context.t b/t/Context.t >index b2091f0f96..e8115df8f0 100755 >--- a/t/Context.t >+++ b/t/Context.t >@@ -31,7 +31,7 @@ BEGIN { > > subtest 'yaml_preference() tests' => sub { > >- plan tests => 3; >+ plan tests => 6; > > my $data = [ 'uno', 'dos', { 'tres' => 'cuatro' } ]; > >@@ -49,6 +49,12 @@ subtest 'yaml_preference() tests' => sub { > 'Invalid YAML on syspref throws a warning'; > is( $pref, undef, 'Invalid YAML on syspref makes it return undef' ); > >+ $context->mock( 'preference', sub { return '{ a : 1 }' }); >+ is( ref( C4::Context->new->yaml_preference('ItemsDeniedRenewal') ), 'HASH', 'Got a hash as expected' ); >+ $context->mock( 'preference', sub { return '[ 1, 2 ]' }); >+ warning_like { $pref = C4::Context->new->yaml_preference('ITEMSDENIEDRENEWAL') } qr/Hashref expected/, 'Array not accepted for ItemsDeniedRenewal'; >+ is( $pref, undef, 'Returned undef' ); >+ > $context->unmock( 'preference' ); > }; > >-- >2.30.2
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 32478
:
144633
|
150685
|
150687
|
150688
|
150689
|
150690
|
151136
|
151726
|
151727
|
151728
|
151729
|
151730
|
151731
| 151732