Page MenuHomePhabricator

Stabilize sorting of feed stories with similar strength
ClosedPublic

Authored by epriestley on May 22 2019, 12:04 AM.
Tags
None
Referenced Files
F13131891: D20540.id48984.diff
Wed, May 1, 5:55 PM
Unknown Object (File)
Tue, Apr 30, 11:31 AM
Unknown Object (File)
Mon, Apr 29, 2:32 PM
Unknown Object (File)
Sat, Apr 27, 2:16 PM
Unknown Object (File)
Fri, Apr 26, 7:38 AM
Unknown Object (File)
Wed, Apr 24, 10:38 PM
Unknown Object (File)
Fri, Apr 19, 5:27 PM
Unknown Object (File)
Fri, Apr 19, 3:14 AM
Subscribers

Details

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:

Screen_Shot_2019-05-21_at_4.18.18_PM.png (934×1 px, 198 KB)

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").

Screen Shot 2019-05-21 at 4.57.41 PM.png (239×455 px, 22 KB)

Diff Detail

Repository
rP Phabricator
Branch
stable1
Lint
Lint Passed
Unit
Tests Passed
Build Status
Buildable 22860
Build 31361: Run Core Tests
Build 31360: arc lint + arc unit

Event Timeline

This revision is now accepted and ready to land.May 22 2019, 9:18 PM
richardvanvelzen added inline comments.
src/applications/transactions/storage/PhabricatorApplicationTransaction.php
1364–1395

Just a quick note - the other values were multiplied by 100 whereas these are by 1000. This causes more useful transactions (like accepting a revision) to have a lower action strength.

src/applications/transactions/storage/PhabricatorApplicationTransaction.php
1364–1395

Thanks! See D20622.