diff --git a/app/Jobs/ScheduledJobManager.php b/app/Jobs/ScheduledJobManager.php index 4c3beb97cd..c218a53652 100644 --- a/app/Jobs/ScheduledJobManager.php +++ b/app/Jobs/ScheduledJobManager.php @@ -64,15 +64,23 @@ class ScheduledJobManager implements ShouldQueue private int $skippedCount = 0; + /** + * One key of TYPES, or null for all types. + * + * Declared with a default instead of promoted, so jobs queued by older versions without this property still run. + */ + public ?string $type = null; + /** * @param string|null $type One key of TYPES, or null for all types. */ - public function __construct(public ?string $type = null) + public function __construct(?string $type = null) { if ($type !== null && ! array_key_exists($type, self::TYPES)) { throw new \InvalidArgumentException("Unknown scheduled job type [{$type}]."); } + $this->type = $type; $this->onQueue(crons_queue()); } diff --git a/tests/Unit/ScheduledJobManagerLegacyPayloadTest.php b/tests/Unit/ScheduledJobManagerLegacyPayloadTest.php new file mode 100644 index 0000000000..4aa846c684 --- /dev/null +++ b/tests/Unit/ScheduledJobManagerLegacyPayloadTest.php @@ -0,0 +1,18 @@ +middleware(); + + expect($job->type)->toBeNull() + ->and($middleware[0])->toBeInstanceOf(WithoutOverlapping::class) + ->and($middleware[0]->key)->toBe('scheduled-job-manager'); +});