From 162068a7b48a8daffdb198ec9ab5033ef65be3f0 Mon Sep 17 00:00:00 2001 From: Mark Tompsett Date: Tue, 30 Jan 2018 17:49:44 +0000 Subject: [PATCH] Bug 20101: Follow-up - quiet warns If the user has never run the tools, the system preference won't exist, the JSON will be empty, and warns will trigger. TEST PLAN --------- 1) back up systempreferences and log files as desired. 2) in sql client: S> delete from systempreferences where variable='automatic_item_modification_by_age_configuration'; S> quit 3) run the following commands on a kohadevbox: echo | sudo tee /var/log/koha/kohadev/plack-error.log restart_all 4) test the first patch 5) cat /var/log/koha/kohadev/plack-error.log -- notice there is a nasty warn 6) apply this patch 7) repeat steps 3-5 -- this time no nasty warns 8) run koha qa test tools Signed-off-by: Kyle M Hall --- misc/cronjobs/automatic_item_modification_by_age.pl | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/misc/cronjobs/automatic_item_modification_by_age.pl b/misc/cronjobs/automatic_item_modification_by_age.pl index e944ac8c11..33ee8210a7 100755 --- a/misc/cronjobs/automatic_item_modification_by_age.pl +++ b/misc/cronjobs/automatic_item_modification_by_age.pl @@ -23,7 +23,10 @@ pod2usage(1) if $help; $verbose = 1 unless $confirm; # Load configuration from the syspref -my $syspref_content = C4::Context->preference('automatic_item_modification_by_age_configuration'); +C4::Context::clear_syspref_cache; +my $syspref_content = C4::Context->preference('automatic_item_modification_by_age_configuration') // q{}; +pod2usage({ -message => 'Set up automatic item modifications by age rules in tools first!', -exitval => 1 }) if $syspref_content !~ /\S/xsm; + my $rules = eval { JSON::from_json( $syspref_content ) }; pod2usage({ -message => "Unable to load the configuration : $@", -exitval => 1 }) if $@; -- 2.24.1 (Apple Git-126)