Skip to content

[2.x] fix: recognise a finished scheduler run without a removed Symfony method - #4897

Merged
imorland merged 1 commit into
2.xfrom
im/schedule-run-command-name
Aug 5, 2026
Merged

[2.x] fix: recognise a finished scheduler run without a removed Symfony method#4897
imorland merged 1 commit into
2.xfrom
im/schedule-run-command-name

Conversation

@imorland

@imorland imorland commented Aug 5, 2026

Copy link
Copy Markdown
Member

The listener that records when the scheduler last ran compared the finished command against ScheduleRunCommand::getDefaultName():

if ($command === 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/console resolves 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\Server dispatches CommandFinished with the command's own getName():

new CommandFinished($event->getCommand()->getName(), ...)

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 $signature and getName() 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:

  • a finished schedule:run records flarum:schedule:last_run
  • another command finishing leaves it alone
  • the name the listener matches is still the one Laravel declares, read back from the attribute

I 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.

…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.
@imorland
imorland requested a review from a team as a code owner August 5, 2026 12:28
@imorland imorland added this to the 2.0.0-rc.6 milestone Aug 5, 2026
@imorland
imorland merged commit cf81af4 into 2.x Aug 5, 2026
24 checks passed
@imorland
imorland deleted the im/schedule-run-command-name branch August 5, 2026 12:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant