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

(-)a/C4/Letters.pm (-2 / +8 lines)
Lines 217-224 sub GetLettersAvailableForALibrary { Link Here
217
    }
217
    }
218
218
219
    return [
219
    return [
220
        map      { $letters{$_} }
220
        map  { $letters{$_} }
221
            sort { $letters{$a}->{name} cmp $letters{$b}->{name} }
221
        sort { $letters{$a}->{name} cmp $letters{$b}->{name} }
222
            keys %letters
222
            keys %letters
223
    ];
223
    ];
224
224
Lines 1029-1034 sub SendQueuedMessages { Link Here
1029
    Koha::Exceptions::BadParameter->throw("Parameter message_id cannot be empty if passed.")
1029
    Koha::Exceptions::BadParameter->throw("Parameter message_id cannot be empty if passed.")
1030
        if ( exists( $params->{message_id} ) && !$params->{message_id} );
1030
        if ( exists( $params->{message_id} ) && !$params->{message_id} );
1031
1031
1032
    my $MessageQueueMode = C4::Context->preference('MessageQueueMode');
1033
1034
    return 0 unless ( $MessageQueueMode eq 'on' || $MessageQueueMode eq 'plugin' );
1035
1032
    if ( C4::Context->config("enable_plugins") ) {
1036
    if ( C4::Context->config("enable_plugins") ) {
1033
        my @plugins = Koha::Plugins->new->GetPlugins(
1037
        my @plugins = Koha::Plugins->new->GetPlugins(
1034
            {
1038
            {
Lines 1048-1053 sub SendQueuedMessages { Link Here
1048
        }
1052
        }
1049
    }
1053
    }
1050
1054
1055
    return 0 unless ( $MessageQueueMode eq 'on' );
1056
1051
    my $smtp_transports = {};
1057
    my $smtp_transports = {};
1052
1058
1053
    my $count_messages  = 0;
1059
    my $count_messages  = 0;
(-)a/installer/data/mysql/atomicupdate/bug_37885.pl (+23 lines)
Line 0 Link Here
1
use Modern::Perl;
2
use Koha::Installer::Output qw(say_warning say_failure say_success say_info);
3
4
return {
5
    bug_number  => "37885",
6
    description => "Add ability to disable message queue processing",
7
    up          => sub {
8
        my ($args) = @_;
9
        my ( $dbh, $out ) = @$args{qw(dbh out)};
10
11
        try {
12
            $dbh->do(
13
                q{
14
                INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type` ) VALUES
15
                ('MessageQueueMode','on','on|off|plugins','Search Engine','Choice');
16
            }
17
            );
18
            say_success( $out, "Added new system preference 'MessageQueueMode'" );
19
        } catch {
20
            say_failure( $out, "Failed to add new system preference 'MessageQueueMode'" );
21
        }
22
    },
23
};
(-)a/installer/data/mysql/mandatory/sysprefs.sql (-1 / +2 lines)
Lines 417-422 INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` Link Here
417
('MaxTotalSuggestions','',NULL,'Number of total suggestions used for time limit with NumberOfSuggestionDays','Free'),
417
('MaxTotalSuggestions','',NULL,'Number of total suggestions used for time limit with NumberOfSuggestionDays','Free'),
418
('MembershipExpiryDaysNotice','',NULL,'Send an account expiration notice that a patron\'s card is about to expire after','Integer'),
418
('MembershipExpiryDaysNotice','',NULL,'Send an account expiration notice that a patron\'s card is about to expire after','Integer'),
419
('MergeReportFields','',NULL,'Displayed fields for deleted MARC records after merge','Free'),
419
('MergeReportFields','',NULL,'Displayed fields for deleted MARC records after merge','Free'),
420
('MessageQueueMode','on','on|off|plugins','Search Engine','Choice'),
420
('minPasswordLength','8',NULL,'Specify the minimum length of a patron/staff password','free'),
421
('minPasswordLength','8',NULL,'Specify the minimum length of a patron/staff password','free'),
421
('NewItemsDefaultLocation','','','If set, all new items will have a location of the given Location Code ( Authorized Value type LOC )',''),
422
('NewItemsDefaultLocation','','','If set, all new items will have a location of the given Location Code ( Authorized Value type LOC )',''),
422
('NewsAuthorDisplay','none','none|opac|staff|both','Display the author name for news items.','Choice'),
423
('NewsAuthorDisplay','none','none|opac|staff|both','Display the author name for news items.','Choice'),
Lines 874-877 INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` Link Here
874
('z3950AuthorAuthFields','701,702,700',NULL,'Define the MARC biblio fields for Personal Name Authorities to fill biblio.author','free'),
875
('z3950AuthorAuthFields','701,702,700',NULL,'Define the MARC biblio fields for Personal Name Authorities to fill biblio.author','free'),
875
('z3950NormalizeAuthor','0','','If ON, Personal Name Authorities will replace authors in biblio.author','YesNo'),
876
('z3950NormalizeAuthor','0','','If ON, Personal Name Authorities will replace authors in biblio.author','YesNo'),
876
('z3950Status','','','This syspref allows to define custom YAML based rules for marking items unavailable in z3950 results.','Textarea')
877
('z3950Status','','','This syspref allows to define custom YAML based rules for marking items unavailable in z3950 results.','Textarea')
877
;
878
;
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/admin.pref (+9 lines)
Lines 310-312 Administration: Link Here
310
                "ARRAY": "Searchable array"
310
                "ARRAY": "Searchable array"
311
            - <br>ISO2709 format is recommended as it is faster and takes less space, whereas array format makes the full MARC record searchable.
311
            - <br>ISO2709 format is recommended as it is faster and takes less space, whereas array format makes the full MARC record searchable.
312
            - <br><strong>NOTE:</strong> Making the full record searchable may have a negative effect on relevance ranking of search results.
312
            - <br><strong>NOTE:</strong> Making the full record searchable may have a negative effect on relevance ranking of search results.
313
    Message processing:
314
        -
315
            - "When running the message queue processor"
316
            - pref: MessageQueueMode
317
              default: on
318
              choices:
319
                on: process all messages and plugin hooks
320
                plugins: process plugin hooks only
321
                off: process nothing
(-)a/t/db_dependent/Letters.t (-2 / +46 lines)
Lines 19-25 Link Here
19
19
20
use Modern::Perl;
20
use Modern::Perl;
21
use File::Basename qw(dirname);
21
use File::Basename qw(dirname);
22
use Test::More tests => 104;
22
use Test::More tests => 105;
23
23
24
use Test::MockModule;
24
use Test::MockModule;
25
use Test::Warn;
25
use Test::Warn;
Lines 1825-1827 subtest 'Virtual method ->strftime in notices' => sub { Link Here
1825
};
1825
};
1826
1826
1827
$schema->storage->txn_rollback;
1827
$schema->storage->txn_rollback;
1828
- 
1828
1829
subtest 'Test MessageQueueMode' => sub {
1830
    plan tests => 3;
1831
1832
    my $dbh = C4::Context->dbh;
1833
1834
    my $borrowernumber = Koha::Patron->new(
1835
        {
1836
            firstname    => 'Jane',
1837
            surname      => 'Smith',
1838
            categorycode => $patron_category,
1839
            branchcode   => $library->{branchcode},
1840
            dateofbirth  => $date,
1841
        }
1842
    )->store->borrowernumber;
1843
1844
    $dbh->do(q|DELETE FROM message_queue|);
1845
    $my_message = {
1846
        'letter' => {
1847
            'content'      => 'a message',
1848
            'metadata'     => 'metadata',
1849
            'code'         => 'TEST_MESSAGE',
1850
            'content_type' => 'text/plain',
1851
            'title'        => 'message title'
1852
        },
1853
        'borrowernumber'         => $borrowernumber,
1854
        'to_address'             => undef,
1855
        'message_transport_type' => 'sms',
1856
        'from_address'           => 'from@example.com'
1857
    };
1858
1859
    my $id = C4::Letters::EnqueueLetter($my_message);
1860
1861
    t::lib::Mocks::mock_preference( 'MessageQueueMode', 'off' );
1862
    C4::Letters::SendQueuedMessages();
1863
    is( Koha::Notice::Messages->find($id)->status, 'pending', 'Message is pending for off' );
1864
1865
    t::lib::Mocks::mock_preference( 'MessageQueueMode', 'plugin' );
1866
    C4::Letters::SendQueuedMessages();
1867
    is( Koha::Notice::Messages->find($id)->status, 'pending', 'Message is pending for plugin' );
1868
1869
    t::lib::Mocks::mock_preference( 'MessageQueueMode', 'on' );
1870
    C4::Letters::SendQueuedMessages();
1871
    is( Koha::Notice::Messages->find($id)->status, 'failed', 'Message is failed for on' );
1872
};

Return to bug 37885