Changeset View
Changeset View
Standalone View
Standalone View
src/applications/badges/editor/PhabricatorBadgesEditor.php
Show First 20 Lines • Show All 112 Lines • ▼ Show 20 Lines | $body->addLinkSection( | ||||
PhabricatorEnv::getProductionURI('/badges/view/'.$object->getID().'/')); | PhabricatorEnv::getProductionURI('/badges/view/'.$object->getID().'/')); | ||||
return $body; | return $body; | ||||
} | } | ||||
protected function getMailSubjectPrefix() { | protected function getMailSubjectPrefix() { | ||||
return pht('[Badge]'); | return pht('[Badge]'); | ||||
} | } | ||||
protected function applyFinalEffects( | |||||
PhabricatorLiskDAO $object, | |||||
array $xactions) { | |||||
$badge_phid = $object->getPHID(); | |||||
foreach ($xactions as $xaction) { | |||||
switch ($xaction->getTransactionType()) { | |||||
case PhabricatorBadgesBadgeAwardTransaction::TRANSACTIONTYPE: | |||||
case PhabricatorBadgesBadgeRevokeTransaction::TRANSACTIONTYPE: | |||||
$user_phids = $xaction->getNewValue(); | |||||
break; | |||||
default: | |||||
$user_phids = id(new PhabricatorBadgesAwardQuery()) | |||||
->setViewer($this->getActor()) | |||||
->withBadgePHIDs(array($badge_phid)) | |||||
->execute(); | |||||
$user_phids = mpull($user_phids, 'getRecipientPHID'); | |||||
break; | |||||
} | |||||
} | |||||
epriestley: This block overwrites `$user_phids` for each transaction, but should add them to a list instead. | |||||
foreach ($user_phids as $user_phid) { | |||||
PhabricatorUserCache::clearCache( | |||||
PhabricatorUserBadgesCacheType::KEY_BADGES, | |||||
$user_phid); | |||||
} | |||||
epriestleyUnsubmitted Not Done Inline ActionsPrefer PhabricatorUserCache::clearCaches($key, $user_phids) which can execute in one query instead of one query per affected user. epriestley: Prefer `PhabricatorUserCache::clearCaches($key, $user_phids)` which can execute in one query… | |||||
return $xactions; | |||||
} | |||||
} | } |
This block overwrites $user_phids for each transaction, but should add them to a list instead.
It's possible to apply transactions of both types at the same time (for example, in Conduit, apply both an "award" transaction and a "name" transaction in one request, or "award" one user and "revoke" another at the same time).
If you do, whichever one applies later wins, and the $user_phids for the other transaction get overwritten. If you award to "A" and revoke from "B" at the same time, only "A" or "B" will get their cache cleared.