From 4250719d100814b996b9e0000f608005b1a4508b Mon Sep 17 00:00:00 2001 From: epriestley Date: Mon, 18 May 2015 12:29:32 -0700 Subject: [PATCH] Destroy notifications properly from `bin/remove destroy` Summary: Fixes T8237. This table is unusual and doesn't have an `id` column, so `delete()` doesn't actually know how to delete records and fails. Test Plan: - Used `bin/remove destroy` to destroy an object with notifications, as per T8237. - Applied patch. - Used `bin/remove destroy` to get a clean delete. - Verified related notifications vanished from notification menu. Reviewers: btrahan Reviewed By: btrahan Subscribers: epriestley Maniphest Tasks: T8237 Differential Revision: https://secure.phabricator.com/D12907 --- .../system/engine/PhabricatorDestructionEngine.php | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/applications/system/engine/PhabricatorDestructionEngine.php b/src/applications/system/engine/PhabricatorDestructionEngine.php index c5b813169c..eddc2f73fb 100644 --- a/src/applications/system/engine/PhabricatorDestructionEngine.php +++ b/src/applications/system/engine/PhabricatorDestructionEngine.php @@ -116,13 +116,14 @@ final class PhabricatorDestructionEngine extends Phobject { } private function destroyNotifications($object_phid) { - $notifications = id(new PhabricatorFeedStoryNotification())->loadAllWhere( - 'primaryObjectPHID = %s', - $object_phid); + $table = id(new PhabricatorFeedStoryNotification()); + $conn_w = $table->establishConnection('w'); - foreach ($notifications as $notification) { - $notification->delete(); - } + queryfx( + $conn_w, + 'DELETE FROM %T WHERE primaryObjectPHID = %s', + $table->getTableName(), + $object_phid); } }