From 4056cca427549e645cbd0515500914b50feae01a Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Fri, 5 Feb 2016 12:39:07 +0100 Subject: Only dispatch the delete event, when the deletion was successful --- lib/private/comments/manager.php | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'lib/private/comments') 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); } -- cgit v1.2.3