@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Don't mark subscribes/mentions as "Lock Overridden"

Summary:
See PHI1209. When a task is in "Hard Lock" mode, it's still possible to apply some changes to it. Notably:

- You can subscribe/unsubscribe.
- You can mention it on another object.
- You can add a relationship from some other object to it (e.g., select it as a "Parent Task" for some other task).

Currently, these types of edits will show a "Lock Overridden" timeline emblem icon. However, they should not: you didn't override a lock to make these changes, they just bypass locks.

For now, special case these cases (self subscribe/unsubscribe + inverse edge edits) so they don't get the little icon, since I think this list is exhaustive today.

Some day we should modularize this, but we'd need code like this anyway (since TYPE_SUBSCRIBE is not modular yet), and this seems unlikely to cause problems even if it's a bit rough.

Test Plan:
- Hard-locked a task.
- Subscribed/unsubscribed, mentioned, relationship'd it as a non-author. No timeline emblems.
- Soft-locked a task.
- Subscribed/unsubscribed, mentioned, relationship'd it, no timeline emblems.
- Clicked "Edit", answered "yes" to the override prompt, edited it. Got a timeline emblem.
- Added some comments and stuff to a normal non-locked task, no emblems.

Reviewers: amckinley

Reviewed By: amckinley

Differential Revision: https://secure.phabricator.com/D20513

+53 -1
+53 -1
src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php
··· 1164 1164 1165 1165 foreach ($xactions as $xaction) { 1166 1166 if ($was_locked) { 1167 - $xaction->setIsLockOverrideTransaction(true); 1167 + $is_override = $this->isLockOverrideTransaction($xaction); 1168 + if ($is_override) { 1169 + $xaction->setIsLockOverrideTransaction(true); 1170 + } 1168 1171 } 1169 1172 1170 1173 $xaction->setObjectPHID($object->getPHID()); ··· 5202 5205 } 5203 5206 5204 5207 return $xaction->getBodyForMail(); 5208 + } 5209 + 5210 + private function isLockOverrideTransaction( 5211 + PhabricatorApplicationTransaction $xaction) { 5212 + 5213 + // See PHI1209. When an object is locked, certain types of transactions 5214 + // can still be applied without requiring a policy check, like subscribing 5215 + // or unsubscribing. We don't want these transactions to show the "Lock 5216 + // Override" icon in the transaction timeline. 5217 + 5218 + // We could test if a transaction did no direct policy checks, but it may 5219 + // have done additional policy checks during validation, so this is not a 5220 + // reliable test (and could cause false negatives, where edits which did 5221 + // override a lock are not marked properly). 5222 + 5223 + // For now, do this in a narrow way and just check against a hard-coded 5224 + // list of non-override transaction situations. Some day, this should 5225 + // likely be modularized. 5226 + 5227 + 5228 + // Inverse edge edits don't interact with locks. 5229 + if ($this->getIsInverseEdgeEditor()) { 5230 + return false; 5231 + } 5232 + 5233 + // For now, all edits other than subscribes always override locks. 5234 + $type = $xaction->getTransactionType(); 5235 + if ($type !== PhabricatorTransactions::TYPE_SUBSCRIBERS) { 5236 + return true; 5237 + } 5238 + 5239 + // Subscribes override locks if they affect any users other than the 5240 + // acting user. 5241 + 5242 + $acting_phid = $this->getActingAsPHID(); 5243 + 5244 + $old = array_fuse($xaction->getOldValue()); 5245 + $new = array_fuse($xaction->getNewValue()); 5246 + $add = array_diff_key($new, $old); 5247 + $rem = array_diff_key($old, $new); 5248 + 5249 + $all = $add + $rem; 5250 + foreach ($all as $phid) { 5251 + if ($phid !== $acting_phid) { 5252 + return true; 5253 + } 5254 + } 5255 + 5256 + return false; 5205 5257 } 5206 5258 5207 5259