Bugzilla – Attachment 19512 Details for
Bug 5342
Serial claiming improvements
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 5342: Catch errors raise by sendmail
Bug-5342-Catch-errors-raise-by-sendmail.patch (text/plain), 6.55 KB, created by
Jonathan Druart
on 2013-07-10 08:06:13 UTC
(
hide
)
Description:
Bug 5342: Catch errors raise by sendmail
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2013-07-10 08:06:13 UTC
Size:
6.55 KB
patch
obsolete
>From 48a27df14be01e279e2a598e7cb75fb4d3a8ab15 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@biblibre.com> >Date: Wed, 10 Jul 2013 10:01:59 +0200 >Subject: [PATCH] Bug 5342: Catch errors raise by sendmail > >For example, Mail::Sendmail can raise an error if no 'From' address if >defined. >--- > C4/Letters.pm | 20 +++++++++++++++----- > C4/Serials.pm | 7 ++++++- > acqui/lateorders.pl | 2 +- > .../prog/en/modules/serials/claims.tt | 6 ++++-- > members/memberentry.pl | 2 +- > serials/claims.pl | 8 ++++++-- > 6 files changed, 33 insertions(+), 12 deletions(-) > >diff --git a/C4/Letters.pm b/C4/Letters.pm >index da17cb4..a223708 100644 >--- a/C4/Letters.pm >+++ b/C4/Letters.pm >@@ -309,7 +309,10 @@ sub SendAlerts { > Message => Encode::encode( "utf8", "" . $letter->{content} ), > 'Content-Type' => 'text/plain; charset="utf8"', > ); >- sendmail(%mail) or carp $Mail::Sendmail::error; >+ unless ( sendmail(%mail) ) { >+ carp $Mail::Sendmail::error; >+ return { error => $Mail::Sendmail::error }; >+ } > } > } > elsif ( $type eq 'claimacquisition' or $type eq 'claimissues' ) { >@@ -351,7 +354,7 @@ sub SendAlerts { > push @email, $databookseller->{contemail} if $databookseller->{contemail}; > unless (@email) { > warn "Bookseller $dataorders->[0]->{booksellerid} without emails"; >- return { error => "no_email" }; >+ return { error => "no_to_address" }; > } > > my $userenv = C4::Context->userenv; >@@ -375,7 +378,11 @@ sub SendAlerts { > Message => Encode::encode( "utf8", "" . $letter->{content} ), > 'Content-Type' => 'text/plain; charset="utf8"', > ); >- sendmail(%mail) or carp $Mail::Sendmail::error; >+ >+ unless ( sendmail(%mail) ) { >+ carp $Mail::Sendmail::error; >+ return { error => $Mail::Sendmail::error }; >+ } > > logaction( > "ACQUISITION", >@@ -404,7 +411,7 @@ sub SendAlerts { > want_librarian => 1, > ) or return; > >- return { error => "no_email" } unless $externalid->{'emailaddr'}; >+ return { error => "no_to_address" } unless $externalid->{'emailaddr'}; > my %mail = ( > To => $externalid->{'emailaddr'}, > From => $branchdetails->{'branchemail'} || C4::Context->preference("KohaAdminEmailAddress"), >@@ -412,7 +419,10 @@ sub SendAlerts { > Message => Encode::encode( "utf8", $letter->{'content'} ), > 'Content-Type' => 'text/plain; charset="utf8"', > ); >- sendmail(%mail) or carp $Mail::Sendmail::error; >+ unless ( sendmail(%mail) ) { >+ carp $Mail::Sendmail::error; >+ return { error => $Mail::Sendmail::error }; >+ } > } > } > >diff --git a/C4/Serials.pm b/C4/Serials.pm >index 377f6b4..d649f5c 100644 >--- a/C4/Serials.pm >+++ b/C4/Serials.pm >@@ -1182,7 +1182,12 @@ sub ModSerialStatus { > # check if an alert must be sent... (= a letter is defined & status became "arrived" > if ( $val->{letter} && $status == 2 && $oldstatus != 2 ) { > require C4::Letters; >- C4::Letters::SendAlerts( 'issue', $val->{subscriptionid}, $val->{letter} ); >+ eval { >+ C4::Letters::SendAlerts( 'issue', $val->{subscriptionid}, $val->{letter} ); >+ }; >+ if ( $@ ) { >+ #FIXME Do something... >+ } > } > } > return; >diff --git a/acqui/lateorders.pl b/acqui/lateorders.pl >index 7c2b3f3..f33fa3c 100755 >--- a/acqui/lateorders.pl >+++ b/acqui/lateorders.pl >@@ -111,7 +111,7 @@ if ($op and $op eq "send_alert"){ > }; > if ( $@ ) { > $template->param(error_claim => $@); >- } elsif ( ref $err and exists $err->{error} and $err->{error} eq "no_email" ) { >+ } elsif ( ref $err and exists $err->{error} and $err->{error} eq "no_to_address" ) { > $template->{VARS}->{'error_claim'} = "no_email"; > } else { > $template->{VARS}->{'info_claim'} = 1; >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/claims.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/claims.tt >index 8cce08d..9393273 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/claims.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/claims.tt >@@ -157,8 +157,10 @@ > <h1>Claims</h1> > > [% IF error_claim %] >- [% IF ( error_claim == "no_email" ) %] >- <div class="error">This vendor has no email</div> >+ [% IF ( error_claim == "no_vendor_email" ) %] >+ <div class="error">This vendor has no email.</div> >+ [% ELSIF ( error_claim == "no_loggedin_user_email" ) %] >+ <div class="error">No email is configured for this account.</div> > [% ELSE %] > <div class="error">[% error_claim %]</div> > [% END %] >diff --git a/members/memberentry.pl b/members/memberentry.pl >index b7123f2..9e7953e 100755 >--- a/members/memberentry.pl >+++ b/members/memberentry.pl >@@ -367,7 +367,7 @@ if ((!$nok) and $nodouble and ($op eq 'insert' or $op eq 'save')){ > }; > if ( $@ ) { > $template->param(error_alert => $@); >- } elsif ( ref($err) eq "HASH" && defined $err->{error} and $err->{error} eq "no_email" ) { >+ } elsif ( ref($err) eq "HASH" && defined $err->{error} and $err->{error} eq "no_to_address" ) { > $template->{VARS}->{'error_alert'} = "no_email"; > } else { > $template->{VARS}->{'info_alert'} = 1; >diff --git a/serials/claims.pl b/serials/claims.pl >index 446143e..24487ee 100755 >--- a/serials/claims.pl >+++ b/serials/claims.pl >@@ -70,8 +70,12 @@ if (@serialnums) { # i.e. they have been flagged to generate claims > }; > if ( $@ ) { > $template->param(error_claim => $@); >- } elsif ( ref $err and exists $err->{error} and $err->{error} eq "no_email" ) { >- $template->{VARS}->{'error_claim'} = "no_email"; >+ } elsif ( ref $err and exists $err->{error} ) { >+ if ( $err->{error} eq "no_to_address" ) { >+ $template->{VARS}->{'error_claim'} = "no_vendor_email"; >+ } elsif ( $err->{error} =~ m|Bad or missing From address| ) { >+ $template->{VARS}->{'error_claim'} = "no_loggedin_user_email"; >+ } > } else { > $template->{VARS}->{'info_claim'} = 1; > } >-- >1.7.10.4
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 5342
:
8115
|
8116
|
8309
|
8334
|
8335
|
8611
|
8682
|
8683
|
8900
|
8910
|
9168
|
9169
|
9976
|
9977
|
10211
|
10212
|
10245
|
10258
|
14444
|
14445
|
14446
|
16217
|
16218
|
16219
|
19512
|
31277
|
31375
|
31454
|
31694
|
31902
|
32171
|
32172