[2.x] fix(realtime): order users by joined_at in realtime:info#4630
Merged
Conversation
Eloquent's oldest() defaults to a created_at column, but Flarum's users table uses joined_at. The realtime:info command failed with "Unknown column 'created_at' in 'order clause'". Pass 'joined_at' explicitly to match the schema. Fixes #4617
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
php flarum realtime:infofailed withUnknown column 'created_at' in 'order clause'because the command used Eloquent'soldest()without arguments — which defaults to acreated_atcolumn that Flarum'suserstable doesn't have. Flarum usesjoined_atinstead.Fixes #4617
Changes
extensions/realtime/src/Websocket/Console/InfoCommand.php— pass'joined_at'tooldest()explicitly.This is the only place in the framework that hits this pattern (verified via
grep).Why not override
CREATED_ATonUserorAbstractModelAbstractModelis the base for every Flarum model — most usecreated_at, onlyUserusesjoined_at. There's no single column name that fits all.const CREATED_AT = 'joined_at'onUserwould help future callers but makes the model look like it has Eloquent-style timestamps when it doesn't ($timestamps = false). Risk of confusing third-party code that introspects the model.Test plan
php flarum realtime:inforuns to completion in the dev container.