diff --git a/module/VuFind/src/VuFind/ILS/Driver/SierraRest.php b/module/VuFind/src/VuFind/ILS/Driver/SierraRest.php index 73d34e30e2f04440e7728d9d65e013ffa32dd6cf..88a50fde628f49e6d4b786b01ac5499a1897bcfd 100644 --- a/module/VuFind/src/VuFind/ILS/Driver/SierraRest.php +++ b/module/VuFind/src/VuFind/ILS/Driver/SierraRest.php @@ -463,12 +463,19 @@ class SierraRest extends AbstractBase implements TranslatorAwareInterface, $zip = ''; $city = ''; if (!empty($result['names'])) { - $name = $result['names'][0]; - list($lastname, $firstname) = explode(', ', $name, 2); + $nameParts = explode(', ', $result['names'][0], 2); + $lastname = $nameParts[0]; + $firstname = $nameParts[1] ?? ''; } if (!empty($result['addresses'][0]['lines'][1])) { $address = $result['addresses'][0]['lines'][0]; - list($zip, $city) = explode(' ', $result['addresses'][0]['lines'][1], 2); + $postalParts = explode(' ', $result['addresses'][0]['lines'][1], 2); + if (isset($postalParts[1])) { + $zip = $postalParts[0]; + $city = $postalParts[1]; + } else { + $city = $postalParts[0]; + } } $expirationDate = !empty($result['expirationDate']) ? $this->dateConverter->convertToDisplayDate( @@ -598,7 +605,9 @@ class SierraRest extends AbstractBase implements TranslatorAwareInterface, $patron ); if (!empty($result['code'])) { - $msg = $this->formatErrorMessage($result['description']); + $msg = $this->formatErrorMessage( + $result['description'] ?? $result['name'] + ); $finalResult['details'][$itemId] = [ 'item_id' => $itemId, 'success' => false, @@ -649,7 +658,7 @@ class SierraRest extends AbstractBase implements TranslatorAwareInterface, 'GET', $patron ); - if (isset($result['code'])) { + if (!empty($result['code'])) { return [ 'success' => false, 'status' => 146 === $result['code'] @@ -818,11 +827,13 @@ class SierraRest extends AbstractBase implements TranslatorAwareInterface, foreach ($details as $holdId) { $result = $this->makeRequest( - ['v3', 'patrons', 'holds', $holdId], [], 'DELETE', $patron + ['v5', 'patrons', 'holds', $holdId], [], 'DELETE', $patron ); if (!empty($result['code'])) { - $msg = $this->formatErrorMessage($result['description']); + $msg = $this->formatErrorMessage( + $result['description'] ?? $result['name'] + ); $response[$holdId] = [ 'item_id' => $holdId, 'success' => false, @@ -887,7 +898,7 @@ class SierraRest extends AbstractBase implements TranslatorAwareInterface, 'GET', $patron ); - if (isset($result['code'])) { + if (!empty($result['code'])) { // An error was returned $this->error( "Request for pickup locations returned error code: {$result['code']}" @@ -1040,7 +1051,7 @@ class SierraRest extends AbstractBase implements TranslatorAwareInterface, ); if (!empty($result['code'])) { - return $this->holdError($result['description']); + return $this->holdError($result['description'] ?? $result['name']); } return ['success' => true]; } @@ -1171,10 +1182,12 @@ class SierraRest extends AbstractBase implements TranslatorAwareInterface, $patron ); - if (isset($result['code']) && $result['code'] != 0) { + if (!empty($result['code'])) { return [ 'success' => false, - 'status' => $this->formatErrorMessage($result['description']) + 'status' => $this->formatErrorMessage( + $result['description'] ?? $result['name'] + ) ]; } return ['success' => true, 'status' => 'change_password_ok'];