diff --git a/application/Espo/Core/Utils/ScheduledJob.php b/application/Espo/Core/Utils/ScheduledJob.php index c24361ea31..a62e6483cf 100644 --- a/application/Espo/Core/Utils/ScheduledJob.php +++ b/application/Espo/Core/Utils/ScheduledJob.php @@ -144,10 +144,11 @@ class ScheduledJob $format = DateTimeUtil::SYSTEM_DATE_TIME_FORMAT; - $selectParams = [ - 'select' => ['id'], - 'leftJoins' => ['scheduledJob'], - 'whereClause' => [ + return (bool) $this->entityManager + ->getRDBRepository(Job::ENTITY_TYPE) + ->select(['id']) + ->leftJoin('scheduledJob') + ->where([ 'OR' => [ [ ['executedAt>=' => $r2From->format($format)], @@ -159,9 +160,7 @@ class ScheduledJob 'scheduledJob.job' => 'Dummy', ] ] - ] - ]; - - return (bool) $this->entityManager->getRDBRepository(Job::ENTITY_TYPE)->findOne($selectParams); + ]) + ->findOne(); } } diff --git a/application/Espo/Core/Webhook/Queue.php b/application/Espo/Core/Webhook/Queue.php index ae4e6faeb3..cbdeaad4a4 100644 --- a/application/Espo/Core/Webhook/Queue.php +++ b/application/Espo/Core/Webhook/Queue.php @@ -41,6 +41,7 @@ use Espo\Core\Utils\Log; use Espo\ORM\EntityManager; use Espo\ORM\Query\Part\Condition as Cond; +use Espo\ORM\Query\SelectBuilder; use Exception; use stdClass; @@ -228,12 +229,16 @@ class Queue $target = null; if ($this->entityManager->hasRepository($targetType)) { + $query = SelectBuilder::create() + ->from($targetType) + ->withDeleted() + ->build(); + $target = $this->entityManager ->getRDBRepository($targetType) - ->where([ - 'id' => $item->get('targetId') - ]) - ->findOne(['withDeleted' => true]); + ->clone($query) + ->where(['id' => $item->get('targetId')]) + ->findOne(); } if (!$target) {