From c94311b73e38e749e8f280b492c858e42b04c66a Mon Sep 17 00:00:00 2001
From: Ere Maijala <ere.maijala@helsinki.fi>
Date: Tue, 10 Apr 2018 15:52:45 +0300
Subject: [PATCH] Fix MultiBackend driver problems caused by Missing records
 without IDs (#1157)

- The underlying problem could be demonstrated by trying to display holds with idsInMyResearch = false.
---
 .../src/VuFind/Controller/MyResearchController.php   |  2 +-
 module/VuFind/src/VuFind/ILS/Driver/MultiBackend.php | 12 +++++-------
 2 files changed, 6 insertions(+), 8 deletions(-)

diff --git a/module/VuFind/src/VuFind/Controller/MyResearchController.php b/module/VuFind/src/VuFind/Controller/MyResearchController.php
index 0c1f2f564ee..815f0bae5f5 100644
--- a/module/VuFind/src/VuFind/Controller/MyResearchController.php
+++ b/module/VuFind/src/VuFind/Controller/MyResearchController.php
@@ -945,7 +945,7 @@ class MyResearchController extends AbstractBase
      */
     protected function getDriverForILSRecord($current)
     {
-        $id = $current['id'] ?? null;
+        $id = $current['id'] ?? '';
         $source = $current['source'] ?? DEFAULT_SEARCH_BACKEND;
         $record = $this->serviceLocator->get('VuFind\Record\Loader')
             ->load($id, $source, true);
diff --git a/module/VuFind/src/VuFind/ILS/Driver/MultiBackend.php b/module/VuFind/src/VuFind/ILS/Driver/MultiBackend.php
index f85770dc16e..da34ab73981 100644
--- a/module/VuFind/src/VuFind/ILS/Driver/MultiBackend.php
+++ b/module/VuFind/src/VuFind/ILS/Driver/MultiBackend.php
@@ -4,7 +4,7 @@
  *
  * PHP version 7
  *
- * Copyright (C) The National Library of Finland 2012-2017.
+ * Copyright (C) The National Library of Finland 2012-2018.
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2,
@@ -493,7 +493,7 @@ class MultiBackend extends AbstractBase implements \Zend\Log\LoggerAwareInterfac
      */
     public function getRenewDetails($checkoutDetails)
     {
-        $source = $this->getSource($checkoutDetails['id']);
+        $source = $this->getSource($checkoutDetails['id'] ?? '');
         $driver = $this->getDriver($source);
         if ($driver) {
             $details = $driver->getRenewDetails(
@@ -883,7 +883,7 @@ class MultiBackend extends AbstractBase implements \Zend\Log\LoggerAwareInterfac
     public function getCancelHoldDetails($holdDetails)
     {
         $source = $this->getSource(
-            $holdDetails['id'] ? $holdDetails['id'] : $holdDetails['item_id']
+            $holdDetails['id'] ?? $holdDetails['item_id'] ?? ''
         );
         $driver = $this->getDriver($source);
         if ($driver) {
@@ -965,7 +965,7 @@ class MultiBackend extends AbstractBase implements \Zend\Log\LoggerAwareInterfac
      */
     public function getCancelStorageRetrievalRequestDetails($details)
     {
-        $source = $this->getSource($details['id']);
+        $source = $this->getSource($details['id'] ?? '');
         $driver = $this->getDriver($source);
         if ($driver
             && $this->methodSupported(
@@ -1172,9 +1172,7 @@ class MultiBackend extends AbstractBase implements \Zend\Log\LoggerAwareInterfac
      */
     public function getCancelILLRequestDetails($details)
     {
-        $source = $this->getSource(
-            $details['id'] ? $details['id'] : $details['item_id']
-        );
+        $source = $this->getSource($details['id'] ?? $details['item_id'] ?? '');
         $driver = $this->getDriver($source);
         if ($driver
             && $this->methodSupported(
-- 
GitLab