From c044639094fe8bd4ea296c886dba883cc0eefae2 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. Signed-off-by: Tomas Cohen Arazi --- 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 ee457534d57..bcf0083d24d 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 ); + try { + my $search_options = { protocol => [ "OIDC", "OAuth" ] }; - while(my $provider = $providers->next) { - $oauth_configuration->{$provider->code} = decode_json($provider->config); - } + my $providers = Koha::Auth::Identity::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.34.1