[Koha-bugs] [Bug 11120] The date option for the overdue_notices cronjob is broken

bugzilla-daemon at bugs.koha-community.org bugzilla-daemon at bugs.koha-community.org
Wed Oct 23 10:40:39 CEST 2013


http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=11120

--- Comment #1 from Jonathan Druart <jonathan.druart at biblibre.com> ---
Created attachment 22304
  -->
http://bugs.koha-community.org/bugzilla3/attachment.cgi?id=22304&action=edit
Bug 11120: FIX the --date option for overdue_notices cronjob

Bug 7447 introduces the --date option for overdue notices.
This option has never worked: the code is waiting for a value but the
option is defined as a boolean.

This patch fixes the option and change the way to calculate the range of
dates.
This range is now managed in Perl instead of in the SQL query. To do it
in Perl allows to build dates simply using the DateTime and
DateTime::Duration modules.

To test this patch you should have a DB with a lot of overdues, (I
tested on a DB with 512 overdues).
A test plan could be:
1/ Dump your message_queue table
2/ Verify the number of overdues in the database before applying the
  patch:
  mysql> DELETE FROM message_queue;
  perl misc/cronjobs/overdue_notices.pl -v -t
  (the triggered option will generate overdue for today)
  mysql> SELECT COUNT(*) FROM message_queue;
  Note this value 2A

  mysql> DELETE FROM message_queue;
  perl misc/cronjobs/overdue_notices.pl -v
  mysql> SELECT COUNT(*) FROM message_queue;
  Note this value 2B

2/ Apply the patch
4/ Verify the number of overdues generated by the patched script:
  mysql> DELETE FROM message_queue;
  perl misc/cronjobs/overdue_notices.pl -v -t
  mysql> SELECT COUNT(*) FROM message_queue;
  Note this value 4A

  mysql> DELETE FROM message_queue;
  perl misc/cronjobs/overdue_notices.pl -v
  mysql> SELECT COUNT(*) FROM message_queue;
  Note this value 4B

  mysql> DELETE FROM message_queue;
  # The date should be defined depending your dateformat preference
  # and should be the date of the current day
  perl misc/cronjobs/overdue_notices.pl -v -t --date="YYYY-MM-DD"
  mysql> SELECT COUNT(*) FROM message_queue;
  Note this value 4C

  mysql> DELETE FROM message_queue;
  # The date should be defined depending your dateformat preference
  # and should be the date of the current day
  perl misc/cronjobs/overdue_notices.pl -v --date="YYYY-MM-DD"
  mysql> SELECT COUNT(*) FROM message_queue;
  Note this value 4D

5/ Compare the values: All values generated with the -t options should
be equals. Same for values without the -t options.
=> 2A == 4A == 4C and 2B == 4B == 4D

6/ Go back to a normal activity for 3 days or manually change the
date_due for issues in the DB:
  mysql> update issues SET date_due = DATE_SUB(date_due, INTERVAL 3 DAY);
Do again step 4C and 4D with a date equals to today - 3 days.
Values should be the same as 4C and 4D.

-- 
You are receiving this mail because:
You are watching all bug changes.


More information about the Koha-bugs mailing list