]> source.dussan.org Git - nextcloud-server.git/commitdiff
Only dispatch the delete event, when the deletion was successful
authorJoas Schilling <nickvergessen@owncloud.com>
Fri, 5 Feb 2016 11:39:07 +0000 (12:39 +0100)
committerJoas Schilling <nickvergessen@owncloud.com>
Fri, 5 Feb 2016 11:39:07 +0000 (12:39 +0100)
lib/private/comments/manager.php

index 21baeb6fee39b6c14b86a18d551ab7d31ea46996..36b2d9d08b8e85d4a29e06e77d72658c67e80c17 100644 (file)
@@ -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);
        }