From e2b87a108229e0d33623d3c9b60e83c9df3e9b34 Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Tue, 2 May 2023 16:27:15 +0000 Subject: [PATCH] Bug 30367: Skip processing if we don't get releases Some repos don't have releases, and this seems to break things as get returns an empty response. Calling from_json on this is the error This simply skips the bad responses to avoid the error: To test: 1. Have this on your koha-conf.xml file: ByWater Solutions bywatersolutions github Theke Solutions thekesolutions gitlab PTFS Europe ptfs-europe github 2. Restart all services: $ restart_all 3. Search for the term 'barclaycard' The search will give an error: malformed JSON string, neither tag, array, object, number, string or atom, at character offset 0 (before "(end of string)") at /usr/share/perl5/JSON.pm line 190 4. Apply patch 5. Repeat 6. No error Note: The barclaycard plugin won't install even though it is returned as of this note - the plugin needs an update I believe, I don't think it's a Koha issue Signed-off-by: David Nind JD amended patch: fix indentation Signed-off-by: Jonathan Druart --- plugins/plugins-home.pl | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/plugins/plugins-home.pl b/plugins/plugins-home.pl index c67156222d7..6e8800e0bb3 100755 --- a/plugins/plugins-home.pl +++ b/plugins/plugins-home.pl @@ -76,8 +76,10 @@ if ($plugins_enabled) { my $response = from_json( get($url) ); foreach my $result ( @{ $response->{items} } ) { next unless $result->{name} =~ /^koha-plugin-/; - my $releases = $result->{url} . "/releases/latest"; - my $release = from_json( get($releases) ); + my $releases = $result->{url} . "/releases/latest"; + my $release_info = get($releases); + next unless $release_info; + my $release = from_json( $release_info ); my $tag_name = $release->{tag_name}; for my $asset ( @{$release->{assets}} ) { if ($asset->{browser_download_url} =~ m/\.kpz$/) { -- 2.25.1