mirror of
https://github.com/flarum/framework.git
synced 2025-01-22 18:42:01 +08:00
Fix potential error when discussion doesn't exist
Not sure how this could be the case, but can't hurt to add the checks. addresses #343
This commit is contained in:
parent
c91f8de1f5
commit
6aafe54ee7
|
@ -37,10 +37,12 @@ class DiscussionMetadataUpdater
|
|||
{
|
||||
$discussion = $event->post->discussion;
|
||||
|
||||
$discussion->comments_count++;
|
||||
$discussion->setLastPost($event->post);
|
||||
$discussion->refreshParticipantsCount();
|
||||
$discussion->save();
|
||||
if ($discussion && $discussion->exists) {
|
||||
$discussion->comments_count++;
|
||||
$discussion->setLastPost($event->post);
|
||||
$discussion->refreshParticipantsCount();
|
||||
$discussion->save();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -66,10 +68,12 @@ class DiscussionMetadataUpdater
|
|||
{
|
||||
$discussion = $event->post->discussion;
|
||||
|
||||
$discussion->refreshCommentsCount();
|
||||
$discussion->refreshParticipantsCount();
|
||||
$discussion->refreshLastPost();
|
||||
$discussion->save();
|
||||
if ($discussion && $discussion->exists) {
|
||||
$discussion->refreshCommentsCount();
|
||||
$discussion->refreshParticipantsCount();
|
||||
$discussion->refreshLastPost();
|
||||
$discussion->save();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -79,7 +83,7 @@ class DiscussionMetadataUpdater
|
|||
{
|
||||
$discussion = $post->discussion;
|
||||
|
||||
if ($discussion->exists) {
|
||||
if ($discussion && $discussion->exists) {
|
||||
$discussion->refreshCommentsCount();
|
||||
$discussion->refreshParticipantsCount();
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user