diff --git a/src/Bundle/ChillMainBundle/Service/AddressGeographicalUnit/RefreshAddressToGeographicalUnitMaterializedViewCronJob.php b/src/Bundle/ChillMainBundle/Service/AddressGeographicalUnit/RefreshAddressToGeographicalUnitMaterializedViewCronJob.php index a141f5100..a836f4124 100644 --- a/src/Bundle/ChillMainBundle/Service/AddressGeographicalUnit/RefreshAddressToGeographicalUnitMaterializedViewCronJob.php +++ b/src/Bundle/ChillMainBundle/Service/AddressGeographicalUnit/RefreshAddressToGeographicalUnitMaterializedViewCronJob.php @@ -32,14 +32,14 @@ class RefreshAddressToGeographicalUnitMaterializedViewCronJob implements CronJob public function canRun(?CronJobExecution $cronJobExecution): bool { - if ($cronJobExecution->getKey() !== $this->getKey()) { - throw new UnexpectedValueException(); - } - if (null === $cronJobExecution) { return true; } + if ($cronJobExecution->getKey() !== $this->getKey()) { + throw new UnexpectedValueException(); + } + $now = new DateTimeImmutable('now'); return $cronJobExecution->getLastStart() < $now->sub(new DateInterval('P1D'))