Skip to content

Commit 673b788

Browse files
authored
Merge pull request Elgg#14753 from jdalsem/6.1-fixes
fixed(notifications): only get url if possible in default body
2 parents 0bfef9f + aa92821 commit 673b788

File tree

1 file changed

+4
-9
lines changed

1 file changed

+4
-9
lines changed

engine/classes/Elgg/Notifications/NotificationEventHandler.php

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -410,16 +410,11 @@ protected function getNotificationBody(\ElggUser $recipient, string $method): st
410410
// Check custom notification body for the action/type/subtype combination
411411
$body_key = "notification:{$this->event->getDescription()}:body";
412412
if (_elgg_services()->translator->languageKeyExists($body_key)) {
413+
$display_name = '';
414+
$container_name = '';
413415
if ($object instanceof \ElggEntity) {
414416
$display_name = $object->getDisplayName();
415-
$container_name = '';
416-
$container = $object->getContainerEntity();
417-
if ($container instanceof \ElggEntity) {
418-
$container_name = $container->getDisplayName();
419-
}
420-
} else {
421-
$display_name = '';
422-
$container_name = '';
417+
$container_name = $object->getContainerEntity()?->getDisplayName();
423418
}
424419

425420
return _elgg_services()->translator->translate($body_key, [
@@ -432,7 +427,7 @@ protected function getNotificationBody(\ElggUser $recipient, string $method): st
432427
}
433428

434429
// Fall back to default body
435-
return _elgg_services()->translator->translate('notification:body', [$object->getURL()]);
430+
return _elgg_services()->translator->translate('notification:body', [$object?->getURL()]);
436431
}
437432

438433
/**

0 commit comments

Comments
 (0)