Skip to content

Commit

Permalink
Check if title{_sub,_short} exists before accessing it
Browse files Browse the repository at this point in the history
  • Loading branch information
David Maus committed Jan 2, 2024
1 parent de1b3a8 commit 220c76d
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions module/VuFind/src/VuFind/RecordDriver/DefaultRecord.php
Original file line number Diff line number Diff line change
Expand Up @@ -1210,10 +1210,12 @@ public function getSeries()
*/
public function getShortTitle()
{
if (is_array($this->fields['title_short'])) {
$title = $this->fields['title_short'][0];
} else {
$title = $this->fields['title_short'];
if (array_key_exists('title_short', $this->fields)) {
if (is_array($this->fields['title_short'])) {
$title = $this->fields['title_short'][0];
} else {
$title = $this->fields['title_short'];
}
}
return $title ?? '';
}
Expand Down Expand Up @@ -1348,10 +1350,12 @@ public function getThumbnail($size = 'small')
*/
public function getTitle()
{
if (is_array($this->fields['title'])) {
$title = $this->fields['title'][0];
} else {
$title = $this->fields['title'];
if (array_key_exists('title', $this->fields)) {
if (is_array($this->fields['title'])) {
$title = $this->fields['title'][0];
} else {
$title = $this->fields['title'];
}
}
return $title ?? '';
}
Expand Down

0 comments on commit 220c76d

Please sign in to comment.