Bugzilla – Attachment 161795 Details for
Bug 35969
Improve error message, remove some logging when sending a cart from the OPAC
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 35969: Add error code in opac-sendbasket.pl
Bug-35969-Add-error-code-in-opac-sendbasketpl.patch (text/plain), 4.23 KB, created by
David Nind
on 2024-02-06 22:07:54 UTC
(
hide
)
Description:
Bug 35969: Add error code in opac-sendbasket.pl
Filename:
MIME Type:
Creator:
David Nind
Created:
2024-02-06 22:07:54 UTC
Size:
4.23 KB
patch
obsolete
>From 8787a188d8649c8e5b995aa66e2b872bbd5b06c4 Mon Sep 17 00:00:00 2001 >From: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >Date: Thu, 1 Feb 2024 07:55:55 +0000 >Subject: [PATCH] Bug 35969: Add error code in opac-sendbasket.pl > >No need to carp about empty basket or no reply address. >Just add a simple explanation on the form. > >Note that it makes no sense to show the form if the patron >has no email address. We need it as reply-to. > >Test plan: >Try opac-sendbasket.pl?bib_list=null >Remove email address from your account, try again. > >Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >Signed-off-by: David Nind <david@davidnind.com> >--- > .../en/modules/opac-sendbasketform.tt | 8 ++++- > opac/opac-sendbasket.pl | 30 ++++++++----------- > 2 files changed, 19 insertions(+), 19 deletions(-) > >diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-sendbasketform.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-sendbasketform.tt >index 577f149503..87ed2fef43 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-sendbasketform.tt >+++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-sendbasketform.tt >@@ -22,7 +22,13 @@ > > [% IF ( error ) %] > <div class="alert alert-warning"> >- <p>There was an error sending the cart.</p> >+ [% IF error == 'NO_BODY' %] >+ <p>There was an error sending the cart: No valid biblio records found.</p> >+ [% ELSIF error == 'NO_REPLY_ADDRESS' %] >+ <p>Since we do not have your email address, we cannot send a mail. We need your email address as reply-to address.</p> >+ [% ELSE %] >+ <p>There was an error sending the cart.</p> >+ [% END %] > </div> > [% END %] > >diff --git a/opac/opac-sendbasket.pl b/opac/opac-sendbasket.pl >index d0ff9fc53a..dde0343672 100755 >--- a/opac/opac-sendbasket.pl >+++ b/opac/opac-sendbasket.pl >@@ -21,13 +21,9 @@ use Modern::Perl; > > use CGI qw ( -utf8 ); > use Encode; >-use Carp qw( carp ); >-use Try::Tiny qw( catch try ); > >-use C4::Biblio qw( >- GetMarcSubjects >-); >-use C4::Auth qw( get_template_and_user ); >+use C4::Auth qw( get_template_and_user ); >+use C4::Biblio qw(GetMarcSubjects); > use C4::Output qw( output_html_with_http_headers ); > use C4::Templates; > use Koha::Biblios; >@@ -44,11 +40,13 @@ my ( $template, $borrowernumber, $cookie ) = get_template_and_user( > type => "opac", > } > ); >+my $patron = Koha::Patrons->find($borrowernumber); >+my $user_email = $patron ? $patron->notice_email_address : undef; > > my $bib_list = $query->param('bib_list') || ''; > my $email_add = $query->param('email_add'); > >-if ( $email_add ) { >+if ( $email_add && $user_email ) { > die "Wrong CSRF token" > unless Koha::Token->new->check_csrf( > { >@@ -57,9 +55,6 @@ if ( $email_add ) { > } > ); > >- my $patron = Koha::Patrons->find($borrowernumber); >- my $user_email = $patron->notice_email_address; >- > my $comment = $query->param('comment'); > > my @bibs = split( /\//, $bib_list ); >@@ -70,12 +65,7 @@ if ( $email_add ) { > } > > if ( !defined $iso2709 ) { >- carp "Error sending mail: empty basket"; >- $template->param( error => 1 ); >- } >- elsif ( !defined $user_email or $user_email eq '' ) { >- carp "Error sending mail: sender's email address is invalid"; >- $template->param( error => 1 ); >+ $template->param( error => 'NO_BODY' ); > } > else { > my %loops = ( biblio => \@bibs, ); >@@ -118,8 +108,12 @@ if ( $email_add ) { > $template->param( email_add => $email_add ); > output_html_with_http_headers $query, $cookie, $template->output, undef, > { force_no_caching => 1 }; >-} >-else { >+ >+} elsif( !$user_email ) { >+ $template->param( email_add => 1, error => 'NO_REPLY_ADDRESS' ); >+ output_html_with_http_headers $query, $cookie, $template->output; >+ >+} else { > my $new_session_id = $query->cookie('CGISESSID'); > $template->param( > bib_list => $bib_list, >-- >2.30.2
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 35969
:
161713
|
161795
|
161804
|
163773
|
163774
|
164635
|
164636