Skip to content

Commit

Permalink
Fix: link from media to non-existing note causes null-pointer exception
Browse files Browse the repository at this point in the history
  • Loading branch information
Greg Roach committed Aug 11, 2019
1 parent 761225c commit 4dcd46f
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions app/Media.php
Expand Up @@ -106,16 +106,20 @@ protected static function fetchGedcomRecord($xref, $tree_id)
public function getNote()
{
$note = $this->getFirstFact('NOTE');
if ($note) {
$text = $note->getValue();
if (preg_match('/^@' . WT_REGEX_XREF . '@$/', $text)) {
$text = $note->getTarget()->getNote();

if ($note instanceof Fact) {
$target = $note->getTarget();

if ($target instanceof Note) {
$text = $target->getNote();
} else {
$text = $note->getValue();
}

return $text;
} else {
return '';
}

return '';
}

/**
Expand Down

0 comments on commit 4dcd46f

Please sign in to comment.