]> git.mxchange.org Git - friendica.git/commitdiff
Fixes issue 5321: Likes can be undone and comments can be deleted again (#5557)
authorMichael Vogel <icarus@dabo.de>
Sun, 5 Aug 2018 04:35:11 +0000 (06:35 +0200)
committerTobias Diekershoff <tobias.diekershoff@gmx.net>
Sun, 5 Aug 2018 04:35:11 +0000 (06:35 +0200)
src/Model/Item.php

index e02be950b18db3f48eee97dc6b17d72c01652350..f2b227a0dabded5ce3b38b2580b76443f7056894 100644 (file)
@@ -1057,10 +1057,10 @@ class Item extends BaseObject
                DBA::delete('item-delivery-data', ['iid' => $item['id']]);
 
                if (!empty($item['iaid']) && !DBA::exists('item', ['iaid' => $item['iaid'], 'deleted' => false])) {
-                       DBA::delete('item-activity', ['id' => $item['iaid']]);
+                       DBA::delete('item-activity', ['id' => $item['iaid']], ['cascade' => false]);
                }
                if (!empty($item['icid']) && !DBA::exists('item', ['icid' => $item['icid'], 'deleted' => false])) {
-                       DBA::delete('item-content', ['id' => $item['icid']]);
+                       DBA::delete('item-content', ['id' => $item['icid']], ['cascade' => false]);
                }
                // When the permission set will be used in photo and events as well,
                // this query here needs to be extended.
@@ -3032,15 +3032,7 @@ class Item extends BaseObject
 
                // If it exists, mark it as deleted
                if (DBA::isResult($like_item)) {
-                       // Already voted, undo it
-                       $fields = ['deleted' => true, 'unseen' => true, 'changed' => DateTimeFormat::utcNow()];
-                       /// @todo Consider using self::update - but before doing so, check the side effects
-                       DBA::update('item', $fields, ['id' => $like_item['id']]);
-
-                       // Clean up the Diaspora signatures for this like
-                       DBA::delete('sign', ['iid' => $like_item['id']]);
-
-                       Worker::add(PRIORITY_HIGH, "Notifier", "like", $like_item['id']);
+                       self::deleteById($like_item['id']);
 
                        if (!$event_verb_flag || $like_item['verb'] == $activity) {
                                return true;