From 2f2b134e5873cf44c943efa5227f543425739dc3 Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Sun, 5 Aug 2018 06:35:11 +0200 Subject: [PATCH] Fixes issue 5321: Likes can be undone and comments can be deleted again (#5557) --- src/Model/Item.php | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/src/Model/Item.php b/src/Model/Item.php index e02be950b..f2b227a0d 100644 --- a/src/Model/Item.php +++ b/src/Model/Item.php @@ -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;