From 6dc1f4d5fef9f140cafc59bffdf4b0d6a31a19d6 Mon Sep 17 00:00:00 2001 From: Victor Grousset Date: Wed, 17 Jan 2018 15:28:14 +0100 Subject: [PATCH] Bug 20076: Overdues: remove redundant message when patrons don't have email addresses When running overdue_notices.pl, one email message is sent to the library containing all the print versions of the related notices. But since a past enhancement, one message of the type print also is created for each of such notices. So now we have two print overdue notice generations. Which is why the email message is not longer relevant as it's superseded by the individual and ready to print messages. Test plan 1. Check the size of the message queue With the following SQL query (using an SQL report if you want) SELECT COUNT(*) FROM message_queue; 2. Run misc/cronjobs/overdue_notices.pl 3. Check the size of the message queue To ensure that no other overdues will create noise in this test plan. Or you can take them into account. 4. Choose a patron with no email address 5. Create an overdue (checkout an item and unfold "Checkout settings" and set a date in the past which is compatible with what you find in staff:/cgi-bin/koha/tools/overduerules.pl 6. Run misc/cronjobs/overdue_notices.pl 7. Check that you have two new messages in the queue 8. Inspect these two messages SELECT * FROM message_queue ORDER BY time_queued DESC LIMIT 2 \G 1. One has the type "print" and the borrowernumber matching the patron. 2. The other has subject: Overdue Notices borrowernumber: NULL message_transport_type: email and contains "These messages were not sent directly to the patrons." This is the one we don't want anymore. Because it's now obsolete due to the first message. 9. Apply this patch 10. Run misc/cronjobs/overdue_notices.pl 11. Check that only the print message is now generated and not the "Overdue Notices" one. --- misc/cronjobs/overdue_notices.pl | 31 ++----------------------------- 1 file changed, 2 insertions(+), 29 deletions(-) diff --git a/misc/cronjobs/overdue_notices.pl b/misc/cronjobs/overdue_notices.pl index 8c42335..3fb4e10 100755 --- a/misc/cronjobs/overdue_notices.pl +++ b/misc/cronjobs/overdue_notices.pl @@ -204,12 +204,7 @@ Notices" section of the staff interface to Koha. =head2 Outgoing emails Typically, messages are prepared for each patron with overdue -items. Messages for whom there is no email address on file are -collected and sent as attachments in a single email to each library -administrator, or if that is not set, then to the email address in the -C system preference. - -These emails are staged in the outgoing message queue, as are messages +items. These emails are staged in the outgoing message queue, as are messages produced by other features of Koha. This message queue must be processed regularly by the F program. @@ -262,10 +257,7 @@ administrator email address. C - In this most basic usage, with no command line arguments, all libraries are processed individually, and notices are prepared for all patrons with overdue items for whom we have email -addresses. Messages for those patrons for whom we have no email -address are sent in a single attachment to the library administrator's -email address, or to the address in the KohaAdminEmailAddress system -preference. +addresses. C - sends no email and populates F with information about all overdue @@ -802,25 +794,6 @@ END_SQL $content = ""; } $content .= join( "\n", @output_chunks ); - - my $attachment = { - filename => defined $csvfilename ? 'attachment.csv' : 'attachment.txt', - type => 'text/plain', - content => $content, - }; - - my $letter = { - title => 'Overdue Notices', - content => 'These messages were not sent directly to the patrons.', - }; - C4::Letters::EnqueueLetter( - { letter => $letter, - borrowernumber => undef, - message_transport_type => 'email', - attachments => [$attachment], - to_address => $admin_email_address, - } - ) unless $test_mode; } } -- 2.7.4