diff options
-rw-r--r-- | lib/private/comments/manager.php | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/lib/private/comments/manager.php b/lib/private/comments/manager.php index 21baeb6fee3..36b2d9d08b8 100644 --- a/lib/private/comments/manager.php +++ b/lib/private/comments/manager.php @@ -436,12 +436,6 @@ class Manager implements ICommentsManager { // Ignore exceptions, we just don't fire a hook then $comment = null; } - if ($comment instanceof IComment) { - $this->dispatcher->dispatch(CommentsEvent::EVENT_DELETE, new CommentsEvent( - CommentsEvent::EVENT_DELETE, - $comment - )); - } $qb = $this->dbConn->getQueryBuilder(); $query = $qb->delete('comments') @@ -455,6 +449,14 @@ class Manager implements ICommentsManager { $this->logger->logException($e, ['app' => 'core_comments']); return false; } + + if ($affectedRows > 0 && $comment instanceof IComment) { + $this->dispatcher->dispatch(CommentsEvent::EVENT_DELETE, new CommentsEvent( + CommentsEvent::EVENT_DELETE, + $comment + )); + } + return ($affectedRows > 0); } |