From e8030e906d61ed17b556ad7a13d4c9c3ddd0f53d Mon Sep 17 00:00:00 2001 From: David Cook Date: Thu, 3 Nov 2022 09:32:03 -0300 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 ee457534d5..5ebe6edbc9 100644 --- a/Koha/REST/V1.pm +++ b/Koha/REST/V1.pm @@ -138,12 +138,17 @@ sub startup { }; my $oauth_configuration = {}; - my $search_options = { protocol => [ "OIDC", "OAuth" ] }; - my $providers = Koha::Auth::Identity::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.25.1