An open-source, self-hostable PaaS alternative to Vercel, Heroku & Netlify that lets you easily deploy static sites, databases, full-stack applications and 360+ one-click services on your own servers.
PHP coolifydatabasesdeploymentdockerdocker-composeinertiajslaravelmariadbmysqlnextjsnodejsphppostgresredisself-hostedself-hostingserverstatic-sitesveltesvelte5
fix(scheduler): accept ScheduledJobManager jobs queued before the upgrade
Andras Bacsai13db52f73029
diff --git a/app/Jobs/ScheduledJobManager.php b/app/Jobs/ScheduledJobManager.phpindex 4c3beb97cd..c218a53652 100644--- a/app/Jobs/ScheduledJobManager.php+++ b/app/Jobs/ScheduledJobManager.php@@ -64,15 +64,23 @@ class ScheduledJobManager implements ShouldQueueprivate 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.phpnew file mode 100644index 0000000000..4aa846c684--- /dev/null+++ b/tests/Unit/ScheduledJobManagerLegacyPayloadTest.php@@ -0,0 +1,18 @@+<?php++use App\Jobs\ScheduledJobManager;+use Illuminate\Queue\Middleware\WithoutOverlapping;+use Tests\TestCase;++uses(TestCase::class);++it('uses the shared lock for a job queued before scheduled job types existed', function () {+ // v4.3.23 serialized ScheduledJobManager without a type property.+ $job = unserialize('O:'.strlen(ScheduledJobManager::class).':"'.ScheduledJobManager::class.'":0:{}');++ $middleware = $job->middleware();++ expect($job->type)->toBeNull()+ ->and($middleware[0])->toBeInstanceOf(WithoutOverlapping::class)+ ->and($middleware[0]->key)->toBe('scheduled-job-manager');+});