From 09a1d199699a56ab7bf258f9f295774d36f5dcd9 Mon Sep 17 00:00:00 2001 From: Mark Noble Date: Mon, 29 Apr 2024 15:12:07 -0600 Subject: [PATCH] Error handling when viewing records that are not linked to a grouped work --- code/web/RecordDrivers/GroupedWorkDriver.php | 20 +++++++++++--------- code/web/release_notes/24.05.00.MD | 2 +- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/code/web/RecordDrivers/GroupedWorkDriver.php b/code/web/RecordDrivers/GroupedWorkDriver.php index db1616edd3..be32979d19 100644 --- a/code/web/RecordDrivers/GroupedWorkDriver.php +++ b/code/web/RecordDrivers/GroupedWorkDriver.php @@ -3267,16 +3267,18 @@ public function getGroupedWorkDetails() { $groupedWork = new GroupedWork(); $groupedWork->permanent_id = $this->getPermanentId(); $groupedWorkDetails = []; - if ($groupedWork->find(true)) { - $groupedWorkDetails['Full title'] = $groupedWork->full_title; - $groupedWorkDetails['Author'] = $groupedWork->author; - $groupedWorkDetails['Grouping Category'] = $groupedWork->grouping_category; - $groupedWorkDetails['Last Update'] = date('Y-m-d H:i:sA', $groupedWork->date_updated); - if ($this->fields != null && array_key_exists('last_indexed', $this->fields)) { - $groupedWorkDetails['Last Indexed'] = date('Y-m-d H:i:sA', strtotime($this->fields['last_indexed'])); + if (!empty($groupedWork->permanent_id)) { + if ($groupedWork->find(true)) { + $groupedWorkDetails['Full title'] = $groupedWork->full_title; + $groupedWorkDetails['Author'] = $groupedWork->author; + $groupedWorkDetails['Grouping Category'] = $groupedWork->grouping_category; + $groupedWorkDetails['Last Update'] = date('Y-m-d H:i:sA', $groupedWork->date_updated); + if ($this->fields != null && array_key_exists('last_indexed', $this->fields)) { + $groupedWorkDetails['Last Indexed'] = date('Y-m-d H:i:sA', strtotime($this->fields['last_indexed'])); + } + } else { + $groupedWorkDetails['Deleted?'] = 'This work has been deleted from the database and should be re-indexed'; } - } else { - $groupedWorkDetails['Deleted?'] = 'This work has been deleted from the database and should be re-indexed'; } return $groupedWorkDetails; } diff --git a/code/web/release_notes/24.05.00.MD b/code/web/release_notes/24.05.00.MD index 1db15ef0fa..e2416ac924 100644 --- a/code/web/release_notes/24.05.00.MD +++ b/code/web/release_notes/24.05.00.MD @@ -79,7 +79,7 @@ - Work on moving packages for Aspen Discovery indexing code. (*MDN*) - Allow footer logo alt to be inherited from parent theme. (Ticket 131044) (*MDN*) - Fix updating saved searches. (*MDN*) - +- Error handling when viewing records that are not linked to a grouped work. (*MDN*) //kirstien ### API Updates