diff --git a/src/Entity/CronJob.php b/src/Entity/CronJob.php index a8b0b465abca55554f65347c25ac98ce3ca21075..fcb54f4d249ed0d8630e79f804caab512f5df63e 100644 --- a/src/Entity/CronJob.php +++ b/src/Entity/CronJob.php @@ -323,8 +323,12 @@ class CronJob extends ConfigEntityBase implements CronJobInterface { try { $plugin = $this->getPlugin(); - if (!$plugin || !$this->shouldRun($request_time, $force)) { - $this->logger->warning('Cron job @job should not be running.', ['@job' => $this->label()]); + if (!$plugin) { + $this->logger->warning('Cron job @job could not be run: missing plugin.', ['@job' => $this->label()]); + return FALSE; + } + if (!$this->shouldRun($request_time, $force)) { + // Do nothing: this job is not scheduled to be run at this time. return FALSE; } diff --git a/tests/src/Unit/Entity/CronJobTest.php b/tests/src/Unit/Entity/CronJobTest.php index 1d08ff35a55c1a5c5d8479f85387e03d359e826c..8bbf647b7c014db328a00602ee922985874591f3 100644 --- a/tests/src/Unit/Entity/CronJobTest.php +++ b/tests/src/Unit/Entity/CronJobTest.php @@ -128,7 +128,12 @@ class CronJobTest extends UnitTestCase { $this->assertEquals($expected, $last_run_time_is_set, 'Last run time is correct.'); $this->assertEquals($expected, $status, 'Cron run is executed.'); - $this->assertEquals(!$locked, $this->state->get('state.message_logged'), 'Message is logged'); + if (!$locked && !$should_run) { + $this->assertEquals($locked, $this->state->get('state.message_logged'), 'Message is logged'); + } + else { + $this->assertEquals(!$locked, $this->state->get('state.message_logged'), 'Message is logged'); + } } /**