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

(-)a/C4/Letters.pm (-3 / +3 lines)
Lines 921-933 sub EnqueueLetter { Link Here
921
    my $dbh       = C4::Context->dbh();
921
    my $dbh       = C4::Context->dbh();
922
    my $statement = << 'ENDSQL';
922
    my $statement = << 'ENDSQL';
923
INSERT INTO message_queue
923
INSERT INTO message_queue
924
( borrowernumber, subject, content, metadata, letter_code, message_transport_type, status, time_queued, to_address, from_address, reply_address, content_type, failure_code )
924
( letter_id, borrowernumber, subject, content, metadata, letter_code, message_transport_type, status, time_queued, to_address, from_address, reply_address, content_type, failure_code )
925
VALUES
925
VALUES ( ?, ?, ?, ?, ?, ?, ?, ?, CAST(NOW() AS DATETIME), ?, ?, ?, ?, ? )
926
( ?,              ?,       ?,       ?,        ?,           ?,                      ?,      CAST(NOW() AS DATETIME),       ?,          ?,            ?,           ?,              ? )
927
ENDSQL
926
ENDSQL
928
927
929
    my $sth    = $dbh->prepare($statement);
928
    my $sth    = $dbh->prepare($statement);
930
    my $result = $sth->execute(
929
    my $result = $sth->execute(
930
        $params->{letter}->{id} || undef,         # letter.id
931
        $params->{'borrowernumber'},              # borrowernumber
931
        $params->{'borrowernumber'},              # borrowernumber
932
        $params->{'letter'}->{'title'},           # subject
932
        $params->{'letter'}->{'title'},           # subject
933
        $params->{'letter'}->{'content'},         # content
933
        $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 3843-3848 DROP TABLE IF EXISTS `message_queue`; Link Here
3843
/*!40101 SET character_set_client = utf8 */;
3843
/*!40101 SET character_set_client = utf8 */;
3844
CREATE TABLE `message_queue` (
3844
CREATE TABLE `message_queue` (
3845
  `message_id` int(11) NOT NULL AUTO_INCREMENT,
3845
  `message_id` int(11) NOT NULL AUTO_INCREMENT,
3846
  `letter_id` int(11) DEFAULT NULL,
3846
  `borrowernumber` int(11) DEFAULT NULL,
3847
  `borrowernumber` int(11) DEFAULT NULL,
3847
  `subject` mediumtext COLLATE utf8mb4_unicode_ci DEFAULT NULL,
3848
  `subject` mediumtext COLLATE utf8mb4_unicode_ci DEFAULT NULL,
3848
  `content` mediumtext COLLATE utf8mb4_unicode_ci DEFAULT NULL,
3849
  `content` mediumtext COLLATE utf8mb4_unicode_ci DEFAULT NULL,
Lines 3860-3865 CREATE TABLE `message_queue` ( Link Here
3860
  PRIMARY KEY (`message_id`),
3861
  PRIMARY KEY (`message_id`),
3861
  KEY `borrowernumber` (`borrowernumber`),
3862
  KEY `borrowernumber` (`borrowernumber`),
3862
  KEY `message_transport_type` (`message_transport_type`),
3863
  KEY `message_transport_type` (`message_transport_type`),
3864
  CONSTRAINT `letter_fk` FOREIGN KEY (`letter_id`) REFERENCES `letter` (`id`) ON DELETE SET NULL ON UPDATE CASCADE,
3863
  CONSTRAINT `messageq_ibfk_1` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE,
3865
  CONSTRAINT `messageq_ibfk_1` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE,
3864
  CONSTRAINT `messageq_ibfk_2` FOREIGN KEY (`message_transport_type`) REFERENCES `message_transport_types` (`message_transport_type`) ON UPDATE CASCADE
3866
  CONSTRAINT `messageq_ibfk_2` FOREIGN KEY (`message_transport_type`) REFERENCES `message_transport_types` (`message_transport_type`) ON UPDATE CASCADE
3865
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
3867
) 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