Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

Likers shown on a post have no stable order when they liked at the same time

Open Beginner friendly
#5,244 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
90/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
laravel, php
Domain
backend, database

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

type/bug
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
  1. Have more than four users like a post in the same second (or give their post_likes rows the same created_at).
  2. Request the post with its likes included, repeatedly or on different database drivers.
  3. 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

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from flarum/framework

All issues in flarum/framework

Similar issues

More PHP issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.