From 8e1600ba83fdbb27824fb78259257d6cc547dc34 Mon Sep 17 00:00:00 2001 From: epriestley Date: Wed, 31 Jul 2019 12:40:53 -0700 Subject: [PATCH] (stable) Don't try to emit project board update events if there are no projects to update Summary: Ref T4900. We may execute a bad query here if the task has no projects at all. Test Plan: Edited a task with no new or old projects. Instead of an exception, things worked. Maniphest Tasks: T4900 Differential Revision: https://secure.phabricator.com/D20689 --- .../editor/ManiphestTransactionEditor.php | 44 ++++++++++--------- 1 file changed, 23 insertions(+), 21 deletions(-) diff --git a/src/applications/maniphest/editor/ManiphestTransactionEditor.php b/src/applications/maniphest/editor/ManiphestTransactionEditor.php index 247f5ce1fe..ed98ad8ad8 100644 --- a/src/applications/maniphest/editor/ManiphestTransactionEditor.php +++ b/src/applications/maniphest/editor/ManiphestTransactionEditor.php @@ -879,34 +879,36 @@ final class ManiphestTransactionEditor $project_phids = array_fuse($old_phids) + array_fuse($new_phids); $project_phids = array_keys($project_phids); - $projects = id(new PhabricatorProjectQuery()) - ->setViewer(PhabricatorUser::getOmnipotentUser()) - ->withPHIDs($project_phids) - ->execute(); + if ($project_phids) { + $projects = id(new PhabricatorProjectQuery()) + ->setViewer(PhabricatorUser::getOmnipotentUser()) + ->withPHIDs($project_phids) + ->execute(); - $notify_projects = array(); - foreach ($projects as $project) { - $notify_projects[$project->getPHID()] = $project; - foreach ($project->getAncestorProjects() as $ancestor) { - $notify_projects[$ancestor->getPHID()] = $ancestor; + $notify_projects = array(); + foreach ($projects as $project) { + $notify_projects[$project->getPHID()] = $project; + foreach ($project->getAncestorProjects() as $ancestor) { + $notify_projects[$ancestor->getPHID()] = $ancestor; + } } - } - foreach ($notify_projects as $key => $project) { - if (!$project->getHasWorkboard()) { - unset($notify_projects[$key]); + foreach ($notify_projects as $key => $project) { + if (!$project->getHasWorkboard()) { + unset($notify_projects[$key]); + } } - } - $notify_phids = array_keys($notify_projects); + $notify_phids = array_keys($notify_projects); - if ($notify_phids) { - $data = array( - 'type' => 'workboards', - 'subscribers' => $notify_phids, - ); + if ($notify_phids) { + $data = array( + 'type' => 'workboards', + 'subscribers' => $notify_phids, + ); - PhabricatorNotificationClient::tryToPostMessage($data); + PhabricatorNotificationClient::tryToPostMessage($data); + } } }