View | Details | Raw Unified | Return to bug 31626
Collapse All | Expand All

(-)a/C4/Letters.pm (-3 / +3 lines)
Lines 922-934 sub EnqueueLetter { Link Here
922
    my $dbh       = C4::Context->dbh();
922
    my $dbh       = C4::Context->dbh();
923
    my $statement = << 'ENDSQL';
923
    my $statement = << 'ENDSQL';
924
INSERT INTO message_queue
924
INSERT INTO message_queue
925
( borrowernumber, subject, content, metadata, letter_code, message_transport_type, status, time_queued, to_address, from_address, reply_address, content_type, failure_code )
925
( letter_id, borrowernumber, subject, content, metadata, letter_code, message_transport_type, status, time_queued, to_address, from_address, reply_address, content_type, failure_code )
926
VALUES
926
VALUES ( ?, ?, ?, ?, ?, ?, ?, ?, CAST(NOW() AS DATETIME), ?, ?, ?, ?, ? )
927
( ?,              ?,       ?,       ?,        ?,           ?,                      ?,      CAST(NOW() AS DATETIME),       ?,          ?,            ?,           ?,              ? )
928
ENDSQL
927
ENDSQL
929
928
930
    my $sth    = $dbh->prepare($statement);
929
    my $sth    = $dbh->prepare($statement);
931
    my $result = $sth->execute(
930
    my $result = $sth->execute(
931
        $params->{letter}->{id} || undef,         # letter.id
932
        $params->{'borrowernumber'},              # borrowernumber
932
        $params->{'borrowernumber'},              # borrowernumber
933
        $params->{'letter'}->{'title'},           # subject
933
        $params->{'letter'}->{'title'},           # subject
934
        $params->{'letter'}->{'content'},         # content
934
        $params->{'letter'}->{'content'},         # content
(-)a/installer/data/mysql/atomicupdate/bug_31626.pl (+15 lines)
Line 0 Link Here
1
use Modern::Perl;
2
3
return {
4
    bug_number => "31626",
5
    description => "Add letter id to the message queue table",
6
    up => sub {
7
        my ($args) = @_;
8
        my ($dbh, $out) = @$args{qw(dbh out)};
9
        $dbh->do(q{
10
            ALTER TABLE message_queue
11
            ADD COLUMN letter_id INT(11) NULL DEFAULT NULL AFTER message_id,
12
            ADD CONSTRAINT letter_fk FOREIGN KEY (letter_id) REFERENCES letter(id) ON DELETE SET NULL ON UPDATE CASCADE
13
        });
14
    },
15
};
(-)a/installer/data/mysql/kohastructure.sql (+2 lines)
Lines 3846-3851 DROP TABLE IF EXISTS `message_queue`; Link Here
3846
/*!40101 SET character_set_client = utf8 */;
3846
/*!40101 SET character_set_client = utf8 */;
3847
CREATE TABLE `message_queue` (
3847
CREATE TABLE `message_queue` (
3848
  `message_id` int(11) NOT NULL AUTO_INCREMENT,
3848
  `message_id` int(11) NOT NULL AUTO_INCREMENT,
3849
  `letter_id` int(11) DEFAULT NULL,
3849
  `borrowernumber` int(11) DEFAULT NULL,
3850
  `borrowernumber` int(11) DEFAULT NULL,
3850
  `subject` mediumtext COLLATE utf8mb4_unicode_ci DEFAULT NULL,
3851
  `subject` mediumtext COLLATE utf8mb4_unicode_ci DEFAULT NULL,
3851
  `content` mediumtext COLLATE utf8mb4_unicode_ci DEFAULT NULL,
3852
  `content` mediumtext COLLATE utf8mb4_unicode_ci DEFAULT NULL,
Lines 3863-3868 CREATE TABLE `message_queue` ( Link Here
3863
  PRIMARY KEY (`message_id`),
3864
  PRIMARY KEY (`message_id`),
3864
  KEY `borrowernumber` (`borrowernumber`),
3865
  KEY `borrowernumber` (`borrowernumber`),
3865
  KEY `message_transport_type` (`message_transport_type`),
3866
  KEY `message_transport_type` (`message_transport_type`),
3867
  CONSTRAINT `letter_fk` FOREIGN KEY (`letter_id`) REFERENCES `letter` (`id`) ON DELETE SET NULL ON UPDATE CASCADE,
3866
  CONSTRAINT `messageq_ibfk_1` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE,
3868
  CONSTRAINT `messageq_ibfk_1` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE,
3867
  CONSTRAINT `messageq_ibfk_2` FOREIGN KEY (`message_transport_type`) REFERENCES `message_transport_types` (`message_transport_type`) ON UPDATE CASCADE
3869
  CONSTRAINT `messageq_ibfk_2` FOREIGN KEY (`message_transport_type`) REFERENCES `message_transport_types` (`message_transport_type`) ON UPDATE CASCADE
3868
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
3870
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
(-)a/t/db_dependent/Letters.t (-2 / +2 lines)
Lines 781-787 subtest 'TranslateNotices' => sub { Link Here
781
781
782
subtest 'Test SMS handling in SendQueuedMessages' => sub {
782
subtest 'Test SMS handling in SendQueuedMessages' => sub {
783
783
784
    plan tests => 13;
784
    plan tests => 14;
785
785
786
    t::lib::Mocks::mock_preference( 'SMSSendDriver', 'Email' );
786
    t::lib::Mocks::mock_preference( 'SMSSendDriver', 'Email' );
787
    t::lib::Mocks::mock_preference('EmailSMSSendDriverFromAddress', '');
787
    t::lib::Mocks::mock_preference('EmailSMSSendDriverFromAddress', '');
Lines 808-813 subtest 'Test SMS handling in SendQueuedMessages' => sub { Link Here
808
        status => 'sent'
808
        status => 'sent'
809
    })->next();
809
    })->next();
810
810
811
    is( $message->letter_id, $messages->[0]->{id}, "Message letter_id is set correctly" );
811
    is( $message->to_address(), '5555555555@kidclamp.rocks', 'SendQueuedMessages populates the to address correctly for SMS by email when to_address not set' );
812
    is( $message->to_address(), '5555555555@kidclamp.rocks', 'SendQueuedMessages populates the to address correctly for SMS by email when to_address not set' );
812
    is(
813
    is(
813
        $message->from_address(),
814
        $message->from_address(),
814
- 

Return to bug 31626