@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.

Stabilize sorting of feed stories with similar strength

Summary:
See PHI1222. When we publish several transactions to feed at once, we sort them by "action strength" to figure out which one gets to be the title story.

This sort currently uses `msort()`, which uses `asort()`, which is not a stable sort and has inconsistent behavior across PHP versions:

{F6463721}

Switch to `msortv()`, which is a stable sort. Previously, see also T6861.

If all transactions have the same strength, we'll now consistently pick the first one.

This probably (?) does not impact anything in the upstream, but is good from a consistency point of view.

Test Plan:
Top story was published after this change and uses the chronologically first transaction as the title story.

Bottom story was published before this change and uses the chronologically second transaction as the title story.

Both stories have two transactions with the same strength ("create" + "add reviewer").

{F6463722}

Reviewers: amckinley

Reviewed By: amckinley

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

+29 -25
+1 -1
src/applications/audit/storage/PhabricatorAuditTransaction.php
··· 50 50 51 51 switch ($type) { 52 52 case self::TYPE_COMMIT: 53 - return 3.0; 53 + return 300; 54 54 } 55 55 56 56 return parent::getActionStrength();
+1 -1
src/applications/differential/storage/DifferentialTransaction.php
··· 130 130 public function getActionStrength() { 131 131 switch ($this->getTransactionType()) { 132 132 case self::TYPE_ACTION: 133 - return 3; 133 + return 300; 134 134 } 135 135 136 136 return parent::getActionStrength();
+1 -1
src/applications/differential/xaction/DifferentialRevisionActionTransaction.php
··· 40 40 } 41 41 42 42 public function getActionStrength() { 43 - return 3; 43 + return 300; 44 44 } 45 45 46 46 public function getRevisionActionOrderVector() {
+1 -1
src/applications/differential/xaction/DifferentialRevisionUpdateTransaction.php
··· 99 99 } 100 100 101 101 public function getActionStrength() { 102 - return 2; 102 + return 200; 103 103 } 104 104 105 105 public function getTitle() {
+1 -1
src/applications/differential/xaction/DifferentialRevisionWrongBuildsTransaction.php
··· 26 26 } 27 27 28 28 public function getActionStrength() { 29 - return 4; 29 + return 400; 30 30 } 31 31 32 32 public function getTitle() {
+1 -1
src/applications/differential/xaction/DifferentialRevisionWrongStateTransaction.php
··· 22 22 } 23 23 24 24 public function getActionStrength() { 25 - return 4; 25 + return 400; 26 26 } 27 27 28 28 public function getTitle() {
+1 -1
src/applications/maniphest/xaction/ManiphestTaskOwnerTransaction.php
··· 31 31 } 32 32 33 33 public function getActionStrength() { 34 - return 1.2; 34 + return 120; 35 35 } 36 36 37 37 public function getActionName() {
+1 -1
src/applications/maniphest/xaction/ManiphestTaskPriorityTransaction.php
··· 27 27 } 28 28 29 29 public function getActionStrength() { 30 - return 1.1; 30 + return 110; 31 31 } 32 32 33 33 public function getActionName() {
+1 -1
src/applications/maniphest/xaction/ManiphestTaskStatusTransaction.php
··· 22 22 } 23 23 24 24 public function getActionStrength() { 25 - return 1.3; 25 + return 130; 26 26 } 27 27 28 28 public function getActionName() {
+1 -1
src/applications/maniphest/xaction/ManiphestTaskTitleTransaction.php
··· 14 14 } 15 15 16 16 public function getActionStrength() { 17 - return 1.4; 17 + return 140; 18 18 } 19 19 20 20 public function getActionName() {
+1 -1
src/applications/pholio/xaction/PholioMockNameTransaction.php
··· 10 10 } 11 11 12 12 public function getActionStrength() { 13 - return 1.4; 13 + return 140; 14 14 } 15 15 16 16 public function applyInternalEffects($object, $value) {
+1 -1
src/applications/phriction/xaction/PhrictionDocumentDeleteTransaction.php
··· 19 19 } 20 20 21 21 public function getActionStrength() { 22 - return 1.5; 22 + return 150; 23 23 } 24 24 25 25 public function getActionName() {
+1 -1
src/applications/phriction/xaction/PhrictionDocumentEditTransaction.php
··· 32 32 } 33 33 34 34 public function getActionStrength() { 35 - return 1.3; 35 + return 130; 36 36 } 37 37 38 38 public function getActionName() {
+1 -1
src/applications/phriction/xaction/PhrictionDocumentMoveToTransaction.php
··· 37 37 } 38 38 39 39 public function getActionStrength() { 40 - return 1.0; 40 + return 100; 41 41 } 42 42 43 43 public function getActionName() {
+1 -1
src/applications/phriction/xaction/PhrictionDocumentTitleTransaction.php
··· 21 21 } 22 22 23 23 public function getActionStrength() { 24 - return 1.4; 24 + return 140; 25 25 } 26 26 27 27 public function getActionName() {
+2 -3
src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php
··· 3249 3249 protected function getStrongestAction( 3250 3250 PhabricatorLiskDAO $object, 3251 3251 array $xactions) { 3252 - return last(msort($xactions, 'getActionStrength')); 3252 + return head(msort($xactions, 'newActionStrengthSortVector')); 3253 3253 } 3254 3254 3255 3255 ··· 3718 3718 PhabricatorLiskDAO $object, 3719 3719 array $xactions) { 3720 3720 3721 - $xactions = msort($xactions, 'getActionStrength'); 3722 - $xactions = array_reverse($xactions); 3721 + $xactions = msortv($xactions, 'newActionStrengthSortVector'); 3723 3722 3724 3723 return array( 3725 3724 'objectPHID' => $object->getPHID(),
+12 -7
src/applications/transactions/storage/PhabricatorApplicationTransaction.php
··· 1363 1363 1364 1364 public function getActionStrength() { 1365 1365 if ($this->isInlineCommentTransaction()) { 1366 - return 0.25; 1366 + return 250; 1367 1367 } 1368 1368 1369 1369 switch ($this->getTransactionType()) { 1370 1370 case PhabricatorTransactions::TYPE_COMMENT: 1371 - return 0.5; 1371 + return 500; 1372 1372 case PhabricatorTransactions::TYPE_SUBSCRIBERS: 1373 1373 if ($this->isSelfSubscription()) { 1374 1374 // Make this weaker than TYPE_COMMENT. 1375 - return 0.25; 1375 + return 250; 1376 1376 } 1377 1377 1378 1378 if ($this->isApplicationAuthor()) { 1379 1379 // When applications (most often: Herald) change subscriptions it 1380 1380 // is very uninteresting. 1381 - return 0.000000001; 1381 + return 1; 1382 1382 } 1383 1383 1384 1384 // In other cases, subscriptions are more interesting than comments 1385 1385 // (which are shown anyway) but less interesting than any other type of 1386 1386 // transaction. 1387 - return 0.75; 1387 + return 750; 1388 1388 case PhabricatorTransactions::TYPE_MFA: 1389 1389 // We want MFA signatures to render at the top of transaction groups, 1390 1390 // on top of the things they signed. 1391 - return 10; 1391 + return 10000; 1392 1392 } 1393 1393 1394 - return 1.0; 1394 + return 1000; 1395 1395 } 1396 1396 1397 1397 public function isCommentTransaction() { ··· 1715 1715 return id(new PhutilSortVector()) 1716 1716 ->addInt(-$this->getDateCreated()) 1717 1717 ->addString($this->getPHID()); 1718 + } 1719 + 1720 + public function newActionStrengthSortVector() { 1721 + return id(new PhutilSortVector()) 1722 + ->addInt(-$this->getActionStrength()); 1718 1723 } 1719 1724 1720 1725