From 507f84f23363746aa9d5912dcb4101e8dad97668 Mon Sep 17 00:00:00 2001 From: Marcel de Rooy Date: Fri, 18 Sep 2015 13:22:42 +0200 Subject: [PATCH] Bug 6810: [QA Follow-up] Exit cronjob if pref not set As per suggestion of Robin on report 14840, it would be better to always run the cronjob and only do something when the pref is set. This patch adds a test in the cronjob and clears the former default of 14 days. Signed-off-by: Marcel de Rooy Removed the pref and ran the dbrev again: Fine. Run the cronjob with -c -v -n: Prints exit warning. Signed-off-by: Tomas Cohen Arazi --- .../bug_6810-add_MembershipExpiryDaysNotice_syspref.sql | 2 +- installer/data/mysql/sysprefs.sql | 2 +- misc/cronjobs/membership_expiry.pl | 8 ++++++++ 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/installer/data/mysql/atomicupdate/bug_6810-add_MembershipExpiryDaysNotice_syspref.sql b/installer/data/mysql/atomicupdate/bug_6810-add_MembershipExpiryDaysNotice_syspref.sql index 19bbba92c9..bafa1b68fb 100644 --- a/installer/data/mysql/atomicupdate/bug_6810-add_MembershipExpiryDaysNotice_syspref.sql +++ b/installer/data/mysql/atomicupdate/bug_6810-add_MembershipExpiryDaysNotice_syspref.sql @@ -1 +1 @@ -INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('MembershipExpiryDaysNotice',14,'Send an account expiration notice that a patron''s card is about to expire after',NULL,'Integer') \ No newline at end of file +INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('MembershipExpiryDaysNotice',NULL,'Send an account expiration notice that a patron''s card is about to expire after',NULL,'Integer') diff --git a/installer/data/mysql/sysprefs.sql b/installer/data/mysql/sysprefs.sql index 1da09b5b0f..13639f049f 100644 --- a/installer/data/mysql/sysprefs.sql +++ b/installer/data/mysql/sysprefs.sql @@ -211,7 +211,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` ('maxoutstanding','5','','maximum amount withstanding to be able make holds','Integer'), ('maxRecordsForFacets','20',NULL,NULL,'Integer'), ('maxreserves','50','','Define maximum number of holds a patron can place','Integer'), -('MembershipExpiryDaysNotice','14','Send an account expiration notice that a patron\'s card is about to expire after',NULL,'Integer'), +('MembershipExpiryDaysNotice',NULL,'Send an account expiration notice that a patron\'s card is about to expire after',NULL,'Integer'), ('minPasswordLength','3',NULL,'Specify the minimum length of a patron/staff password','free'), ('NewItemsDefaultLocation','','','If set, all new items will have a location of the given Location Code ( Authorized Value type LOC )',''), ('noissuescharge','5','','Define maximum amount withstanding before check outs are blocked','Integer'), diff --git a/misc/cronjobs/membership_expiry.pl b/misc/cronjobs/membership_expiry.pl index 4a0f98befd..0cf52c8b71 100755 --- a/misc/cronjobs/membership_expiry.pl +++ b/misc/cronjobs/membership_expiry.pl @@ -132,6 +132,14 @@ pod2usage(1) if $help || !$confirm; cronlogaction(); +my $expdays = C4::Context->preference('MembershipExpiryDaysNotice'); +if( !$expdays ) { + #If the pref is not set, we will exit + warn 'Exiting membership_expiry.pl: MembershipExpiryDaysNotice not set' + if $verbose; + exit; +} + my $admin_adress = C4::Context->preference('KohaAdminEmailAddress'); warn 'getting upcoming membership expires' if $verbose; my $upcoming_mem_expires = C4::Members::GetUpcomingMembershipExpires(); -- 2.39.5