From e71cfeb903279e3c1dacdd14fd32fb3db8bcaab6 Mon Sep 17 00:00:00 2001 From: David Cook Date: Fri, 14 Oct 2022 02:26:58 +0000 Subject: [PATCH] Bug 31378: (follow-up) catch startup error when missing Oauth provider table In theory, this shouldn't come up with a package install, but it could happen with other installations, so best to let it get to the web installer. --- Koha/REST/V1.pm | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/Koha/REST/V1.pm b/Koha/REST/V1.pm index 0451576d30..f5ea5d0d19 100644 --- a/Koha/REST/V1.pm +++ b/Koha/REST/V1.pm @@ -135,12 +135,17 @@ sub startup { }; my $oauth_configuration = {}; - my $search_options = { protocol => [ "OIDC", "OAuth" ] }; - my $providers = Koha::Auth::Providers->search( $search_options ); - - while(my $provider = $providers->next) { - $oauth_configuration->{$provider->code} = decode_json($provider->config); + try { + my $search_options = { protocol => [ "OIDC", "OAuth" ] }; + my $providers = Koha::Auth::Providers->search( $search_options ); + while(my $provider = $providers->next) { + $oauth_configuration->{$provider->code} = decode_json($provider->config); + } } + catch { + my $logger = Koha::Logger->get({ interface => 'api' }); + $logger->warn("Warning: Failed to fetch oauth configuration: " . $_); + }; $self->plugin( 'Koha::REST::Plugin::Pagination' ); $self->plugin( 'Koha::REST::Plugin::Query' ); -- 2.30.2