Likers shown on a post have no stable order when they liked at the same time
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 90/100
Research direction
Start by reading extensions/likes/src/Api/PostResourceFields.php, especially the likes relationship and PostResourceFields::$maxLikes, and reproduce the tie with multiple users liking a post in the same second. The issue identifies the intended ordering change after created_at; verify that repeated requests and supported database drivers return a deterministic set of likers. Add or update a focused test for equal created_at values if the repository’s existing test structure provides one, then run that test.
Written by the indexing model from the issue text.
Description
Current Behavior
The likes relationship orders a post's likers with the actor first, then by created_at, and nothing breaks ties. Likes are stored to the second, so likers who liked in the same second come back in whatever order the database returns them. Which four likers a post shows (PostResourceFields::$maxLikes), and so the response itself, can differ from one request to the next or between database servers. On discuss.flarum.org, about 155,000 likes share about 64,000 distinct timestamps.
Steps to Reproduce
- Have more than four users like a post in the same second (or give their
post_likesrows the samecreated_at). - Request the post with its
likesincluded, repeatedly or on different database drivers. - Nothing in the query fixes which likers are listed, or in what order.
Expected Behavior
A stable order for likers who liked at the same time, for example by user id.
Environment
- Flarum version: 2.0.1
- flarum/likes; any database.
Possible Solution
Add ->orderBy('user_id') after ->orderBy('created_at') in extensions/likes/src/Api/PostResourceFields.php.
Additional Context
Found while comparing responses between versions on a copy of discuss.flarum.org's database.
- Dominant language
- PHP
- Stars
- 6.8k
- Forks
- 889
- Avg merge
- 11h 45m
- Merged PRs (30d)
- 131
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from flarum/framework
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Maintainers usually reply within 1 day
-
Admin search ignores a settings or permissions item's own linkPossibly taken @GBra-4-669 claimed this 2 days ago. Opentype/bug
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Maintainers usually reply within 1 day
-
type/extensibility
Difficulty 2/5 1-3 hours Newbie friendliness 77/100
Maintainers usually reply within 1 day
-
type/bug
Difficulty 2/5 1-3 hours Newbie friendliness 77/100
Maintainers usually reply within 1 day
-
type/bug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
All issues in flarum/framework
Similar issues
-
sync-en
Difficulty 1/5 Under an hour Newbie friendliness 86/100
Maintainers usually reply within 1 day
-
sync-en
Difficulty 1/5 Under an hour Newbie friendliness 78/100
Maintainers usually reply within 2 days
-
Issue: ready for confirmation
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
Перевод устарел
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
LinkStackOrg/LinkStack#1014 · 2 comments ·