Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

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

Aperta Adatta ai principianti
#5,244 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
90/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
laravel, php
Ambito
backend, database

Direzione di ricerca

Inizia leggendo extensions/likes/src/Api/PostResourceFields.php, in particolare la relazione likes e PostResourceFields::$maxLikes, e riproduci il pareggio quando più utenti mettono like a un post nello stesso secondo. Il issue indica la modifica prevista dell’ordine dopo created_at; verifica che richieste ripetute e driver di database supportati restituiscano un insieme deterministico di utenti che hanno messo like. Aggiungi o aggiorna un test mirato per valori created_at uguali se la struttura di test esistente del repository lo prevede, quindi esegui quel test.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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.

Lingua principale
PHP
Stelle
6.8k
Fork
889
Merge medio
12h 36m
PR unite (30g)
135

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di flarum/framework

Tutte le issue di flarum/framework

Issue simili

Altre issue su PHP

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.