diff --git a/src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php b/src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php --- a/src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php +++ b/src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php @@ -2061,6 +2061,35 @@ $this->getActor(), $new_texts); + // Do not re-subscribe mentioned users when editing task description + if ($object instanceof ManiphestTask) { + foreach ($xactions as $xaction) { + $type = $xaction->getTransactionType(); + if ($type == PhabricatorTransactions::TYPE_CREATE) { + break; // assume when core:create exists, it is first in $xactions + } + if ($type == ManiphestTaskDescriptionTransaction::TRANSACTIONTYPE) { + // get current task subscribers + $subscribers_query = id(new PhabricatorEdgeQuery()) + ->withSourcePHIDs(array($object->getPHID())) + ->withEdgeTypes( + array(PhabricatorObjectHasSubscriberEdgeType::EDGECONST)); + $subscribers_query->execute(); + $subscribed_phids = $subscribers_query->getDestinationPHIDs( + array($object->getPHID()), + array(PhabricatorObjectHasSubscriberEdgeType::EDGECONST)); + + // unset phids in task description who are not already subscribers + foreach ($new_phids as $description_mentioned_phid) { + if (!in_array($description_mentioned_phid, $subscribed_phids)) { + unset($new_phids[$description_mentioned_phid]); + } + } + break; + } + } + } + $phids = array_diff($new_phids, $old_phids); } else { $phids = array();