Skip to content

Commit

Permalink
Merge pull request #18 from wedevelopnl/fix/broken-article-page
Browse files Browse the repository at this point in the history
check if author is instance of Member
  • Loading branch information
mirche97 authored May 22, 2024
2 parents 7a8b78e + 59b4810 commit d3b6f7a
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/Menus/Page/PageMenu.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use SilverStripe\CMS\Controllers\ContentController;
use SilverStripe\Control\Controller;
use SilverStripe\ORM\FieldType\DBHTMLText;
use SilverStripe\Security\Member;
use SilverStripe\Versioned\Versioned;
use SilverStripe\View\ArrayData;
use WeDevelop\AdminToolbar\Menus\Page\MenuItems\EditMenuItem;
Expand Down Expand Up @@ -77,7 +78,7 @@ public function getAuthorEditLink(): ?string
{
$author = $this->getPageVersion()?->Author();

if (!$author) {
if (!($author instanceof Member)) {
return null;
}

Expand All @@ -86,7 +87,9 @@ public function getAuthorEditLink(): ?string

public function getAuthorName(): string
{
return $this->getPageVersion()?->Author()->Name ?? _t('Author.UNKNOWN', 'Unknown author');
$author = $this->getPageVersion()?->Author();

return ($author instanceof Member) ? $author->getName() : _t('Author.UNKNOWN', 'Unknown author');
}

private function getPageVersion(): ?\Page
Expand All @@ -101,6 +104,7 @@ private function getPageVersion(): ?\Page

/** @var \Page|null $versioned */
$versioned = Versioned::get_version($controller->ClassName, $controller->ID, $controller->Version);

return $versioned;
}

Expand Down

0 comments on commit d3b6f7a

Please sign in to comment.