From 48a92818cbcec395c530f42996a97678679e1fbd Mon Sep 17 00:00:00 2001 From: Sein Coray Date: Sun, 26 Jun 2022 22:31:30 +0200 Subject: [PATCH 1/3] agent zaps are deleted before the zaps themselves when a hashlist is deleted --- src/inc/utils/HashlistUtils.class.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/inc/utils/HashlistUtils.class.php b/src/inc/utils/HashlistUtils.class.php index 599c5e620..51ed6babf 100644 --- a/src/inc/utils/HashlistUtils.class.php +++ b/src/inc/utils/HashlistUtils.class.php @@ -18,6 +18,7 @@ use DBA\Chunk; use DBA\AgentError; use DBA\Zap; +use DBA\AgentZap; use DBA\Factory; use DBA\Speed; @@ -507,10 +508,16 @@ public static function delete($hashlistId, $user) { $toDelete[] = $superHashlist; } } - Factory::getHashlistHashlistFactory()->massDeletion([Factory::FILTER => $qF]); - + + // when we delete all zaps, we have to make sure that from agentZap, there are no references to zaps of this hashlist $qF = new QueryFilter(Zap::HASHLIST_ID, $hashlist->getId(), "="); + $zapIds = Util::arrayOfIds(Factory::getAgentZapFactory()->filter([Factory::FILTER => $qF])); + $qF1 = new ContainFilter(AgentZap::LAST_ZAP_ID, $zapIds); + $uS = new UpdateSet(AgentZap::LAST_ZAP_ID, null); + Factory::getAgentZapFactory()->massUpdate([Factory::UPDATE => $uS, Factory::FILTER => $qF1]); Factory::getZapFactory()->massDeletion([Factory::FILTER => $qF]); + + Factory::getHashlistHashlistFactory()->massDeletion([Factory::FILTER => $qF]); $payload = new DataSet(array(DPayloadKeys::HASHLIST => $hashlist)); NotificationHandler::checkNotifications(DNotificationType::DELETE_HASHLIST, $payload); From a409e7cfde4c13c6c837184e5bfe2ca3c9f9c268 Mon Sep 17 00:00:00 2001 From: Sein Coray Date: Sun, 26 Jun 2022 22:36:09 +0200 Subject: [PATCH 2/3] fixed factory call for check --- src/inc/utils/HashlistUtils.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/inc/utils/HashlistUtils.class.php b/src/inc/utils/HashlistUtils.class.php index 51ed6babf..f2eebf3c8 100644 --- a/src/inc/utils/HashlistUtils.class.php +++ b/src/inc/utils/HashlistUtils.class.php @@ -511,7 +511,7 @@ public static function delete($hashlistId, $user) { // when we delete all zaps, we have to make sure that from agentZap, there are no references to zaps of this hashlist $qF = new QueryFilter(Zap::HASHLIST_ID, $hashlist->getId(), "="); - $zapIds = Util::arrayOfIds(Factory::getAgentZapFactory()->filter([Factory::FILTER => $qF])); + $zapIds = Util::arrayOfIds(Factory::getZapFactory()->filter([Factory::FILTER => $qF])); $qF1 = new ContainFilter(AgentZap::LAST_ZAP_ID, $zapIds); $uS = new UpdateSet(AgentZap::LAST_ZAP_ID, null); Factory::getAgentZapFactory()->massUpdate([Factory::UPDATE => $uS, Factory::FILTER => $qF1]); @@ -521,7 +521,7 @@ public static function delete($hashlistId, $user) { $payload = new DataSet(array(DPayloadKeys::HASHLIST => $hashlist)); NotificationHandler::checkNotifications(DNotificationType::DELETE_HASHLIST, $payload); - + $qF = new QueryFilter(NotificationSetting::OBJECT_ID, $hashlist->getId(), "="); $notifications = Factory::getNotificationSettingFactory()->filter([Factory::FILTER => $qF]); foreach ($notifications as $notification) { From ca2470088faad69d8de81aa3a99664ee066e54ff Mon Sep 17 00:00:00 2001 From: Romke van Dijk Date: Wed, 29 Jun 2022 10:42:44 +0200 Subject: [PATCH 3/3] Adding changelog. --- doc/changelog.md | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/changelog.md b/doc/changelog.md index 83f04ea65..5b1737225 100644 --- a/doc/changelog.md +++ b/doc/changelog.md @@ -28,6 +28,7 @@ - Fixed sending two to headers when sending emails (issue #751). - Fixed access group not being changed on Hashlist detailed screen (issue #765). - Fixed missing check on permissions for sending notifications (issue #757). +- Fixed not deleting all references (related to zaps) when deleting hashlist (issue #747). ## Enhancements