diff --git a/_config.php b/_config.php index 9e519d4a..71c7914c 100644 --- a/_config.php +++ b/_config.php @@ -5,5 +5,4 @@ // Avoid creating global variables call_user_func(function () { - }); diff --git a/src/Models/FileLink.php b/src/Models/FileLink.php index 0d40b933..55ee97cd 100644 --- a/src/Models/FileLink.php +++ b/src/Models/FileLink.php @@ -28,7 +28,11 @@ public function generateLinkDescription(array $data): string $file = File::get()->byID($fileId); - return $file?->getFilename() ?? ''; + if (!$file?->exists() || !$file->canView()) { + return ''; + } + + return $file->getFilename(); } public function LinkTypeHandlerName(): string diff --git a/src/Models/SiteTreeLink.php b/src/Models/SiteTreeLink.php index f3f611d8..0f41dfb2 100644 --- a/src/Models/SiteTreeLink.php +++ b/src/Models/SiteTreeLink.php @@ -41,7 +41,7 @@ public function generateLinkDescription(array $data): string /** @var SiteTree $page */ $page = SiteTree::get()->byID($pageId); - if (!$page?->exists()) { + if (!$page?->exists() || !$page->canView()) { return ''; }