-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Always sort shares in a reliable way #21311
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Signed-off-by: Joas Schilling <[email protected]>
rullzer
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yepyepyep
good catch
danxuliu
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code makes sense 👍
Run the affected Talk integration tests (sharing/create.feature:722 and sharing/delete.feature:216) 20 times without failures.
Nice catch!
| $aTime = $a->getShareTime()->getTimestamp(); | ||
| $bTime = $b->getShareTime()->getTimestamp(); | ||
| if ($aTime === $bTime) { | ||
| return $a->getId() < $b->getId() ? -1 : 1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could use spaceship here: https://stackoverflow.com/questions/30365346/what-is-the-spaceship-operator-in-php-7
|
/backport to stable19 |
|
Backporting to 19 so we have reliable tests there as well |
Before the sorting wasn't really reliable.
In case you had 2 shares with the same timestamp, you could load them in 2 different orders.
This actually broke the talk integration tests in 90% of the time (when both shares have the same timestamp) while almost always working locally because the requests took a bit long and always working while debugging because then it always was longer than 1 second for me.
Now this makes sure that sorting is always done in the same way and in case of same timestamp it sorts by id.