[2.x] fix: recognise a finished scheduler run without a removed Symfony method - #4897
Merged
Conversation
…ny method The listener that records when the scheduler last ran compared the finished command against `ScheduleRunCommand::getDefaultName()`. That is a static Symfony deprecated in favour of the `#[AsCommand]` attribute and has now removed, so the call is a fatal on Symfony 8 — reached whenever any command finishes, since the listener runs for all of them. It was also asking the wrong thing. `Flarum\Console\Server` dispatches `CommandFinished` with the command's own `getName()`, so the value being compared was never the static's return; reading it back through `getDefaultName()` was an indirect way of writing a constant. Laravel declares that name in `#[AsCommand(name: 'schedule:run')]`, and its `$signature` and `getName()` agree. Adds tests for what had none: that a finished run records the timestamp the admin info screen reports, that another command finishing does not, and that the name the listener matches is still the one Laravel declares.
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.
The listener that records when the scheduler last ran compared the finished command against
ScheduleRunCommand::getDefaultName():Symfony deprecated that static in favour of the
#[AsCommand]attribute and has now removed it, so on Symfony 8 the call is a fatal — and it is reached whenever any command finishes, since the listener runs for all of them.We are not on Symfony 8 yet (
symfony/consoleresolves to 7.4), so nothing is broken today. It surfaced while checking what a wider constraint would cost.It was also asking the wrong question.
Flarum\Console\ServerdispatchesCommandFinishedwith the command's owngetName():so the value being compared was never the static's return value — reading it back through
getDefaultName()was an indirect way of writing a constant. Laravel declares the name in#[AsCommand(name: 'schedule:run')], and its$signatureandgetName()both agree with it.Tests
There were none for this, and a mismatch fails quietly — the timestamp is simply never written, and the admin info screen reports that the scheduler has never run. Three added:
schedule:runrecordsflarum:schedule:last_runI checked they fail if the name is wrong, rather than just passing.
Verified on PHP 8.5.9: 3 tests / 5 assertions green, console integration suite 20/20, core unit 402/402.