From 710c9039ee6a1f465d1615f56ceafd3cb26fb184 Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Tue, 20 Oct 2020 14:40:50 -0300 Subject: [PATCH] Bug 26751: Fix fatal exception if only one repo defined This patch fixes this nasty problem with how XML is parsed: if more than one entry is found, repo => [] is generated. If only one, repo => {}. To test: 1. Have more than one entries in the plugins_repo entry: ByWater Solutions bywatersolutions github Theke Solutions thekesolutions github PTFS Europe ptfs-europe github 2. Search for plugins => SUCCESS: Searching works! 3. Leave only one entry 4. Restart all to refresh things 5. Try searching for plugins => FAIL: Fatal error 6. Apply this patch 7. Repeat 5 => SUCCESS: It doesn't explode anymore! 8. Sign off :-D Signed-off-by: Tomas Cohen Arazi Signed-off-by: Kyle M Hall Signed-off-by: Martin Renvoize Signed-off-by: Jonathan Druart (cherry picked from commit 9e5ea4f5ab81cb500f112a5858130f82a6b4fd65) Signed-off-by: Lucas Gass --- plugins/plugins-home.pl | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/plugins/plugins-home.pl b/plugins/plugins-home.pl index 7d9170c177..63b666fc89 100755 --- a/plugins/plugins-home.pl +++ b/plugins/plugins-home.pl @@ -66,6 +66,12 @@ if ($plugins_enabled) { my @results; if ($plugin_search) { my $repos = C4::Context->config('plugin_repos'); + + # Fix data structure if only one repo defined + if ( ref($repos->{repo}) eq 'HASH' ) { + $repos = { repo => [ $repos->{repo} ] }; + } + foreach my $r ( @{ $repos->{repo} } ) { if ( $r->{service} eq 'github' ) { my $url = "https://api.github.com/search/repositories?q=$plugin_search+user:$r->{org_name}+in:name,description"; -- 2.39.5