From 756d20672a7e9ccf804a68ecace66abc394a5e7b 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 --- plugins/plugins-home.pl | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/plugins/plugins-home.pl b/plugins/plugins-home.pl index 1efcc02ded..47d5262b32 100755 --- a/plugins/plugins-home.pl +++ b/plugins/plugins-home.pl @@ -63,6 +63,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.20.1