diff --git a/application/Espo/Classes/Jobs/Cleanup.php b/application/Espo/Classes/Jobs/Cleanup.php index bbe940781f..f40e019057 100644 --- a/application/Espo/Classes/Jobs/Cleanup.php +++ b/application/Espo/Classes/Jobs/Cleanup.php @@ -609,8 +609,6 @@ class Cleanup implements JobDataLess $repository->deleteFromDb($entity->getId()); - $query = $this->entityManager->getQueryComposer(); - foreach ($entity->getRelationList() as $relation) { if ($entity->getRelationType($relation) !== Entity::MANY_MANY) { continue; @@ -763,6 +761,15 @@ class Cleanup implements JobDataLess 'deleted' => true, ]; + if ( + !$this->entityManager + ->getDefs() + ->getEntity($scope) + ->hasAttribute('deleted') + ) { + continue; + } + if ($this->metadata->get(['entityDefs', $scope, 'fields', 'modifiedAt'])) { $whereClause['modifiedAt<'] = $datetime->format(DateTimeUtil::SYSTEM_DATE_TIME_FORMAT); }