Skip to content

Commit

Permalink
Check that logged in user exists before assigning to post.
Browse files Browse the repository at this point in the history
Resolves an issue where the seeder fails in the migrations because it's usually run in a context where there is no user.

Fixes #480.
  • Loading branch information
Ben Thomson committed Oct 22, 2019
1 parent f4b16de commit aceda91
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion models/Post.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,9 @@ public function beforeSave()
{
if (empty($this->user)) {
$user = BackendAuth::getUser();
$this->user = $user->id;
if (!is_null($user)) {
$this->user = $user->id;
}
}
$this->content_html = self::formatHtml($this->content);
}
Expand Down

0 comments on commit aceda91

Please sign in to comment.