From 56b7d939eafe759da6bdda7aeffa892e9e2deece Mon Sep 17 00:00:00 2001 From: Melroy van den Berg Date: Mon, 4 Nov 2024 21:04:22 +0100 Subject: [PATCH] Fix dead instance query by allowing lastSuccessfulDeliver is null (#1204) --- src/Entity/Instance.php | 3 ++- src/Repository/InstanceRepository.php | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Entity/Instance.php b/src/Entity/Instance.php index 270d9fddd..748ba1707 100644 --- a/src/Entity/Instance.php +++ b/src/Entity/Instance.php @@ -100,6 +100,7 @@ public function getFailedDelivers(): int public function isDead(): bool { - return $this->getLastSuccessfulDeliver() < self::getDateBeforeDead() && $this->getFailedDelivers() >= self::NUMBER_OF_FAILED_DELIVERS_UNTIL_DEAD; + return ($this->getLastSuccessfulDeliver() < self::getDateBeforeDead() || null === $this->getLastSuccessfulDeliver()) + && $this->getFailedDelivers() >= self::NUMBER_OF_FAILED_DELIVERS_UNTIL_DEAD; } } diff --git a/src/Repository/InstanceRepository.php b/src/Repository/InstanceRepository.php index 7b9a8fd03..1ca67be85 100644 --- a/src/Repository/InstanceRepository.php +++ b/src/Repository/InstanceRepository.php @@ -84,7 +84,7 @@ public function getDeadInstances(): array { return $this->createQueryBuilder('i') ->where('i.failedDelivers >= :numToDead') - ->andWhere('i.lastSuccessfulDeliver < :dateBeforeDead') + ->andWhere('i.lastSuccessfulDeliver < :dateBeforeDead OR i.lastSuccessfulDeliver IS NULL') ->setParameter('numToDead', Instance::NUMBER_OF_FAILED_DELIVERS_UNTIL_DEAD) ->setParameter('dateBeforeDead', Instance::getDateBeforeDead()) ->orderBy('i.id')