Bugzilla – Attachment 155459 Details for
Bug 34731
C4::Letters::SendQueuedMessages can be triggered with an undef message_id
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 34731: Throw exception if SendQueuedMessages is passed a bad message_id
Bug-34731-Throw-exception-if-SendQueuedMessages-is.patch (text/plain), 2.85 KB, created by
David Nind
on 2023-09-08 19:48:29 UTC
(
hide
)
Description:
Bug 34731: Throw exception if SendQueuedMessages is passed a bad message_id
Filename:
MIME Type:
Creator:
David Nind
Created:
2023-09-08 19:48:29 UTC
Size:
2.85 KB
patch
obsolete
>From c0ba72127cd2b4773ea38b8464fef46254ae29e2 Mon Sep 17 00:00:00 2001 >From: Kyle M Hall <kyle@bywatersolutions.com> >Date: Thu, 7 Sep 2023 11:04:32 -0400 >Subject: [PATCH] Bug 34731: Throw exception if SendQueuedMessages is passed a > bad message_id > >Test Plan: >1) Apply this patch >2) prove t/db_dependent/Letters.t > >Signed-off-by: David Nind <david@davidnind.com> >--- > C4/Letters.pm | 13 ++++++++----- > t/db_dependent/Letters.t | 18 +++++++++++++++++- > 2 files changed, 25 insertions(+), 6 deletions(-) > >diff --git a/C4/Letters.pm b/C4/Letters.pm >index e070697df4..f7efee76be 100644 >--- a/C4/Letters.pm >+++ b/C4/Letters.pm >@@ -25,19 +25,19 @@ use Module::Load::Conditional qw( can_load ); > > use Try::Tiny; > >-use C4::Members; > use C4::Log qw( logaction ); >+use C4::Members; > use C4::SMS; > use C4::Templates; >-use Koha::SMS::Providers; >- >+use Koha::Auth::TwoFactorAuth; >+use Koha::DateUtils qw( dt_from_string output_pref ); > use Koha::Email; >+use Koha::Exceptions; > use Koha::Notice::Messages; > use Koha::Notice::Templates; > use Koha::Notice::Util; >-use Koha::DateUtils qw( dt_from_string output_pref ); >-use Koha::Auth::TwoFactorAuth; > use Koha::Patrons; >+use Koha::SMS::Providers; > use Koha::SMTP::Servers; > use Koha::Subscriptions; > >@@ -980,6 +980,9 @@ sub SendQueuedMessages { > my $limit = $params->{limit}; > my $where = $params->{where}; > >+ Koha::Exceptions::BadParameter->throw("Parameter message_id cannot be empty if passed.") >+ if ( exists( $params->{message_id} ) && !$params->{message_id} ); >+ > my $smtp_transports = {}; > > my $count_messages = 0; >diff --git a/t/db_dependent/Letters.t b/t/db_dependent/Letters.t >index 3d1e34a6bb..94b5f60633 100755 >--- a/t/db_dependent/Letters.t >+++ b/t/db_dependent/Letters.t >@@ -18,7 +18,7 @@ > # along with Koha; if not, see <http://www.gnu.org/licenses>. > > use Modern::Perl; >-use Test::More tests => 87; >+use Test::More tests => 90; > use Test::MockModule; > use Test::Warn; > use Test::Exception; >@@ -158,6 +158,22 @@ my $yesterday = dt_from_string->subtract( days => 1 ); > Koha::Notice::Messages->find($messages->[0]->{message_id})->time_queued($yesterday)->store; > > # SendQueuedMessages >+ >+throws_ok { >+ C4::Letters::SendQueuedMessages( { message_id => undef } ); >+} >+'Koha::Exceptions::BadParameter', 'Undef message_id throws an exception'; >+ >+throws_ok { >+ C4::Letters::SendQueuedMessages( { message_id => 0 } ); >+} >+'Koha::Exceptions::BadParameter', 'message_id of 0 throws an exception'; >+ >+throws_ok { >+ C4::Letters::SendQueuedMessages( { message_id => q{} } ); >+} >+'Koha::Exceptions::BadParameter', 'Empty string message_id throws an exception'; >+ > my $messages_processed = C4::Letters::SendQueuedMessages( { type => 'email' }); > is($messages_processed, 0, 'No queued messages processed if type limit passed with unused type'); > $messages_processed = C4::Letters::SendQueuedMessages( { type => 'sms' }); >-- >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 34731
:
155325
|
155326
|
155327
|
155459
|
155460
|
155461
|
155478
|
155479
|
155480
|
155481
|
158178
|
158179
|
158180