From 1f0511747d3067080db4edcf70d7e113420cf904 Mon Sep 17 00:00:00 2001 From: Ere Maijala <ere.maijala@helsinki.fi> Date: Mon, 19 Mar 2018 19:07:43 +0200 Subject: [PATCH] Avoid throwing exceptions inside getMyFines. (#1149) - Routinely throwing errors in a non-error situation can be inconvenient for debugging. --- .../Controller/MyResearchController.php | 23 ++++++++++--------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/module/VuFind/src/VuFind/Controller/MyResearchController.php b/module/VuFind/src/VuFind/Controller/MyResearchController.php index ed3953e6861..ff2024c9ac4 100644 --- a/module/VuFind/src/VuFind/Controller/MyResearchController.php +++ b/module/VuFind/src/VuFind/Controller/MyResearchController.php @@ -1359,19 +1359,20 @@ class MyResearchController extends AbstractBase foreach ($result as $row) { // Attempt to look up and inject title: try { - if (!isset($row['id']) || empty($row['id'])) { - throw new \Exception(); - } - $source = $row['source'] ?? DEFAULT_SEARCH_BACKEND; - $row['driver'] = $this->serviceLocator - ->get('VuFind\Record\Loader')->load($row['id'], $source); - if (empty($row['title'])) { - $row['title'] = $row['driver']->getShortTitle(); + if (strlen($row['id'] ?? '') > 0) { + $source = $row['source'] ?? DEFAULT_SEARCH_BACKEND; + $row['driver'] = $this->serviceLocator + ->get('VuFind\Record\Loader')->load($row['id'], $source); + if (empty($row['title'])) { + $row['title'] = $row['driver']->getShortTitle(); + } } } catch (\Exception $e) { - if (!isset($row['title'])) { - $row['title'] = null; - } + // Ignore record loading exceptions... + } + // In case we skipped or failed record loading, make sure title is set. + if (!isset($row['title'])) { + $row['title'] = null; } $fines[] = $row; } -- GitLab