From afdb06db6ea88e542136e95f52ef03f4d5ab557f 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 Signed-off-by: Nick Clemens --- 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 0c35c6f0056..cfb7a597f4a 100644 --- a/Koha/REST/V1.pm +++ b/Koha/REST/V1.pm @@ -140,12 +140,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