Bug 6810: [QA Follow-up] Exit cronjob if pref not set
authorMarcel de Rooy <m.de.rooy@rijksmuseum.nl>
Fri, 18 Sep 2015 11:22:42 +0000 (13:22 +0200)
committerTomas Cohen Arazi <tomascohen@theke.io>
Tue, 6 Oct 2015 14:13:58 +0000 (11:13 -0300)
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 <m.de.rooy@rijksmuseum.nl>
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 <tomascohen@theke.io>
installer/data/mysql/atomicupdate/bug_6810-add_MembershipExpiryDaysNotice_syspref.sql
installer/data/mysql/sysprefs.sql
misc/cronjobs/membership_expiry.pl

index 19bbba9..bafa1b6 100644 (file)
@@ -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')
index 1da09b5..13639f0 100644 (file)
@@ -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'),
index 4a0f98b..0cf52c8 100755 (executable)
@@ -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();