Skip to content

Commit

Permalink
Fix error when showing notes from deleted
Browse files Browse the repository at this point in the history
Fixes #5
  • Loading branch information
Tam committed Jan 6, 2022
1 parent f7fabdf commit 4890f05
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 1.0.6 - 2022-01-06
### Fixed
- Fix error when displaying a note from a suspended or deleted user (Fixes #5)

## 1.0.5 - 2021-06-14
### Fixed
- Fix notes not being visible on drafts / revisions (Fixes #4)
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "ether/notes",
"description": "A note taking field type for Craft CMS 3",
"version": "1.0.5",
"version": "1.0.6",
"type": "craft-plugin",
"license": "proprietary",
"minimum-stability": "dev",
Expand Down
3 changes: 2 additions & 1 deletion src/Service.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ public function getNotesByElement (ElementInterface $element, $translatable = fa
$users = User::find()
->select(new Expression($select))
->id($userIds)
->anyStatus()
->pairs();

$notes = [];
Expand All @@ -93,7 +94,7 @@ public function getNotesByElement (ElementInterface $element, $translatable = fa
$notes[] = new Note([
'id' => $note['id'],
'note' => $note['note'],
'author' => $users[$note['userId']],
'author' => @$users[$note['userId']] ?? '[Deleted]',
'date' => DateTimeHelper::toDateTime($note['dateCreated'])->format(Field::$dateFormat),

'elementId' => $note['elementId'],
Expand Down

0 comments on commit 4890f05

Please sign in to comment.