From b17bf8cf0270631f716c4e41e1d4c73837a95b7e Mon Sep 17 00:00:00 2001
From: Ere Maijala <ere.maijala@helsinki.fi>
Date: Wed, 2 Sep 2020 15:30:35 +0300
Subject: [PATCH] KohaRest: Fix retrieval of pickup locations in non-request
 context.

Fixes selection of home library in profile page.
---
 module/VuFind/src/VuFind/ILS/Driver/KohaRest.php | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/module/VuFind/src/VuFind/ILS/Driver/KohaRest.php b/module/VuFind/src/VuFind/ILS/Driver/KohaRest.php
index 8d5c384fe71..88c458d53fc 100644
--- a/module/VuFind/src/VuFind/ILS/Driver/KohaRest.php
+++ b/module/VuFind/src/VuFind/ILS/Driver/KohaRest.php
@@ -717,19 +717,18 @@ class KohaRest extends \VuFind\ILS\Driver\AbstractBase implements
      */
     public function getPickUpLocations($patron = false, $holdDetails = null)
     {
-        $bibId = $holdDetails['id'];
+        $bibId = $holdDetails['id'] ?? null;
         $itemId = $holdDetails['item_id'] ?? false;
-        $level = isset($holdDetails['level']) && !empty($holdDetails['level'])
-            ? $holdDetails['level'] : 'copy';
-        if ('copy' === $level && false === $itemId) {
-            return [];
-        }
         $requestType
             = array_key_exists('StorageRetrievalRequest', $holdDetails ?? [])
                 ? 'StorageRetrievalRequests' : 'Holds';
         $included = null;
-        if ('Holds' === $requestType) {
+        if ($bibId && 'Holds' === $requestType) {
             // Collect library codes that are to be included
+            $level = !empty($holdDetails['level']) ? $holdDetails['level'] : 'title';
+            if ('copy' === $level && false === $itemId) {
+                return [];
+            }
             if ('copy' === $level) {
                 $result = $this->makeRequest(
                     [
-- 
GitLab