From ae9cbf7b0ac39a7dbf4a834286b61e16c47a6f90 Mon Sep 17 00:00:00 2001 From: Sophie Meynieux Date: Mon, 13 Dec 2010 13:00:31 +0100 Subject: [PATCH] Bug 6090: Empty mails in message_queue are sent Add a new script to purge message_queue table. This script should be run before process_message_queue.pl BibLibre MT4764 --- C4/Letters.pm | 19 ++++++++++- misc/cronjobs/purge_message_queue.pl | 58 ++++++++++++++++++++++++++++++++++ 2 files changed, 76 insertions(+), 1 deletions(-) create mode 100644 misc/cronjobs/purge_message_queue.pl diff --git a/C4/Letters.pm b/C4/Letters.pm index 34e3686..a439036 100644 --- a/C4/Letters.pm +++ b/C4/Letters.pm @@ -42,7 +42,7 @@ BEGIN { $VERSION = 3.01; @ISA = qw(Exporter); @EXPORT = qw( - &GetLetters &getletter &addalert &getalert &delalert &findrelatedto &SendAlerts GetPrintMessages + &GetLetters &getletter &addalert &getalert &delalert &findrelatedto &SendAlerts &GetPrintMessages &DelEmptyMessages ); } @@ -710,6 +710,23 @@ ENDSQL return $sth->fetchall_arrayref({}); } + +=head2 DelEmptyMessages + &DelcwEmptyMessages() + + Delete all messages without subjet nor content + +=cut +sub DelEmptyMessages { + my $dbh = C4::Context->dbh; + + my $sth = $dbh->prepare(" + DELETE FROM message_queue WHERE subject is null and content is null; + "); + $sth->execute(); +} + + =head2 _add_attachements named parameters: diff --git a/misc/cronjobs/purge_message_queue.pl b/misc/cronjobs/purge_message_queue.pl new file mode 100644 index 0000000..9a532da --- /dev/null +++ b/misc/cronjobs/purge_message_queue.pl @@ -0,0 +1,58 @@ + +#!/usr/bin/perl -w + +# Copyright 2010 Biblibre SARL +# +# This file is part of Koha. +# +# Koha is free software; you can redistribute it and/or modify it under the +# terms of the GNU General Public License as published by the Free Software +# Foundation; either version 2 of the License, or (at your option) any later +# version. +# +# Koha is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR +# A PARTICULAR PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with Koha; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +use strict; +use warnings; +use utf8; + +BEGIN { + + # find Koha's Perl modules + # test carefully before changing this + use FindBin; + eval { require "$FindBin::Bin/../kohalib.pl" }; +} + +use Getopt::Long; +use Pod::Usage; +use C4::Letters; + +my ($help); + +GetOptions( + 'help|?' => \$help +); + +if($help){ + print <