Skip to content

Commit

Permalink
ENH Add canView() checks to generateLinkDescription() for relations
Browse files Browse the repository at this point in the history
  • Loading branch information
emteknetnz committed Sep 26, 2023
1 parent 7a16b8b commit 879a3f6
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
1 change: 0 additions & 1 deletion _config.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,4 @@

// Avoid creating global variables
call_user_func(function () {

});
6 changes: 5 additions & 1 deletion src/Models/FileLink.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,11 @@ public function generateLinkDescription(array $data): string

$file = File::get()->byID($fileId);

return $file?->getFilename() ?? '';
if (!$file || !$file->canView()) {
return '';
}

return $file->getFilename();
}

public function LinkTypeHandlerName(): string
Expand Down
2 changes: 1 addition & 1 deletion src/Models/SiteTreeLink.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 '';
}

Expand Down

0 comments on commit 879a3f6

Please sign in to comment.