From 85d5b1c95f0000f95177937d07f08291223e4e38 Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Tue, 28 Jan 2025 14:48:54 -0300 Subject: [PATCH] Bug 38988: Make the polling use case be normal in about page This patch makes choosing `polling` for the `JobsNotificationMethod` system preference not be considered problematic or different than `STOMP`. To test: 1. In `KTD` make sure you have `STOMP` selected 2. Make sure rabbitmq is running: $ ktd --shell k$ sudo -s $ service rabbitmq-server start 3. Go to the about page, 'Server information' => SUCCESS: 'Using RabbitMQ' displayed 4. Stop rabbit $ service rabbitmq-server stop 5. Repeat 3 => SUCCESS: Using Rabbit but fallback to polling 6. Go to the 'System information' tab => SUCCESS: Error message about the broker not functional 7. Choose 'polling' 8. Repeat 3 => FAIL: It says 'Using SQL polling' but in bold face <.< 9. Repeat 6 => FAIL: There's an error about the broker, which we explicitly asked not to use <.< 10. Apply this patch 11. Repeat 3 => SUCCESS: Nothing weird, 'Using SQL polling' displayed. 12. Repeat 6 => SUCCESS: No weird error about the broker. 13. Switch to 'STOMP' => SUCCESS: Behavior is the same with/without rabbit running 14. Sign off :-D Signed-off-by: Tomas Cohen Arazi --- about.pl | 24 ++++++++----------- .../intranet-tmpl/prog/en/modules/about.tt | 10 ++++---- 2 files changed, 16 insertions(+), 18 deletions(-) diff --git a/about.pl b/about.pl index afb58e95556..7b6de763278 100755 --- a/about.pl +++ b/about.pl @@ -178,7 +178,7 @@ if ( $tab eq 'about' ) { $where_is_memcached_config = 'config_only'; } - message_broker_check($template); + job_notification_method_check($template); elasticsearch_check($template); $template->param( @@ -606,7 +606,7 @@ if($tab eq 'sysinfo') { $template->param( warnFastCataloging => $no_FA_framework ); } - message_broker_check($template); + job_notification_method_check($template); #BZ 28267: Warn administrators if there are database rows with a format other than 'DYNAMIC' { @@ -909,22 +909,18 @@ sub elasticsearch_check { } } -sub message_broker_check { - my $template = shift; - { +sub job_notification_method_check { + my ($template) = @_; + + if ( C4::Context->preference('JobsNotificationMethod') eq 'STOMP' ) { + # BackgroundJob - test connection to message broker my $conn = Koha::BackgroundJob->connect; - if (! $conn) { - if (C4::Context->preference('JobsNotificationMethod') eq 'STOMP' ) { - $template->param( warnConnectBroker => 'Error connecting' ); - } else { - $template->param( - warnConnectBroker => C4::Context->preference('JobsNotificationMethod') - ); - } + if ( !$conn ) { + $template->param( warnConnectBroker => 1 ); } } - } +} if ( $tab eq 'database' ) { use Koha::Database::Auditor; diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/about.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/about.tt index 08e81d80982..f2a34e22f2a 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/about.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/about.tt @@ -204,12 +204,14 @@ Message broker: - [% IF warnConnectBroker == 'Error connecting' %] + [% IF warnConnectBroker %] Using SQL polling (Fallback, Error connecting to RabbitMQ) - [% ELSIF warnConnectBroker %] - Using SQL polling [% ELSE %] - Using RabbitMQ + [% IF Koha.Preference('JobsNotificationMethod') == 'polling' %] + Using SQL polling + [% ELSE %] + Using RabbitMQ + [% END %] [% END %] -- 2.48.1