From b5874a08e482196f50af50aa78e43c93c29fb647 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dani=C3=ABl=20Klabbers?= Date: Thu, 22 Sep 2022 10:20:06 +0200 Subject: [PATCH] fix(approval): posts approved for deleted users error In certain edge cases posts get approved through moderative action and throws an error when the user has already been deleted. Ref: DISCUSS-11K on sentry --- extensions/approval/src/Listener/ApproveContent.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/extensions/approval/src/Listener/ApproveContent.php b/extensions/approval/src/Listener/ApproveContent.php index 2fc8acc18..85a828491 100755 --- a/extensions/approval/src/Listener/ApproveContent.php +++ b/extensions/approval/src/Listener/ApproveContent.php @@ -13,7 +13,7 @@ use Flarum\Approval\Event\PostWasApproved; use Flarum\Post\Event\Saving; use Illuminate\Contracts\Events\Dispatcher; -class ApproveContent +class ApproveContent { /** * @param Dispatcher $events @@ -69,7 +69,9 @@ class ApproveContent $discussion->save(); - $user->refreshCommentCount(); - $user->save(); + if ($discussion->user) { + $user->refreshCommentCount(); + $user->save(); + } } }