Bug 30367: Skip processing if we don't get releases
authorNick Clemens <nick@bywatersolutions.com>
Tue, 2 May 2023 16:27:15 +0000 (16:27 +0000)
committerLucas Gass <lucas@bywatersolutions.com>
Tue, 13 Jun 2023 16:13:26 +0000 (16:13 +0000)
commitaaf2d1ac90f79dbd2e9cd38eb10d2ee53ed77e0b
tree5e7f9982d561dd4a5c9c598714ef4ccb27a587cb
parentb0d427115cfa18064cfc0405741aaf0f6a4e2a9a
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:

 <plugin_repos>
    <repo>
        <name>ByWater Solutions</name>
        <org_name>bywatersolutions</org_name>
        <service>github</service>
    </repo>
    <repo>
        <name>Theke Solutions</name>
        <org_name>thekesolutions</org_name>
        <service>gitlab</service>
    </repo>
    <repo>
        <name>PTFS Europe</name>
        <org_name>ptfs-europe</org_name>
        <service>github</service>
    </repo>
 </plugin_repos>

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 <david@davidnind.com>
JD amended patch: fix indentation

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
(cherry picked from commit b12aa543e2e2fe1c46eca4a0e07daa369b033793)
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
(cherry picked from commit 63289fb34ca01a18ad0dca9c064ac07923a99f19)
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
plugins/plugins-home.pl