Bug 21203: ILS-DI - Make GetRecords handle non-existent records
authorJonathan Druart <jonathan.druart@bugs.koha-community.org>
Fri, 10 Aug 2018 15:17:45 +0000 (12:17 -0300)
committerNick Clemens <nick@bywatersolutions.com>
Mon, 20 Aug 2018 14:37:31 +0000 (14:37 +0000)
Caused by
  commit cb336e633bf7e0cb25051a8ed8157af8486a58d7
  Bug 18255: Koha::Biblio - Replace GetBiblioItemByBiblioNumber with Koha::Biblio->biblioitem

Can't call method "biblioitem" on an undefined value at /home/vagrant/kohaclone/C4/ILSDI/Services.pm line 212

Test plan:
- Enable ilsdi
- hit /cgi-bin/koha/ilsdi.pl?service=GetRecords&id=X
With X an existing biblionumber and a non existing one

Both requests must succeed

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Josef Moravec <josef.moravec@gmail.com>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
C4/ILSDI/Services.pm

index 5534d3c..9498a77 100644 (file)
@@ -209,14 +209,13 @@ sub GetRecords {
 
         # Get the biblioitem from the biblionumber
         my $biblio = Koha::Biblios->find( $biblionumber );
-        my $biblioitem = $biblio->biblioitem;
-        if ( $biblioitem ) {
-            $biblioitem = $biblioitem->unblessed;
-        } else {
-            $biblioitem->{code} = "RecordNotFound";
-            # FIXME We should not need to process something else; next?
+        unless ( $biblio ) {
+            push @records, { code => "RecordNotFound" };
+            next;
         }
 
+        my $biblioitem = $biblio->biblioitem->unblessed;
+
         my $embed_items = 1;
         my $record = GetMarcBiblio({
             biblionumber => $biblionumber,