diff --git a/pkg/job-queue/CalculateRootJobStatusService.php b/pkg/job-queue/CalculateRootJobStatusService.php index 4268158b1..41dd350b9 100644 --- a/pkg/job-queue/CalculateRootJobStatusService.php +++ b/pkg/job-queue/CalculateRootJobStatusService.php @@ -69,6 +69,7 @@ protected function calculateRootJobStatus(array $jobs) $success = 0; foreach ($jobs as $job) { + $this->jobStorage->refreshJobEntity($job); switch ($job->getStatus()) { case Job::STATUS_NEW: $new++; diff --git a/pkg/job-queue/Doctrine/JobStorage.php b/pkg/job-queue/Doctrine/JobStorage.php index 385ee4d38..0ee459e50 100644 --- a/pkg/job-queue/Doctrine/JobStorage.php +++ b/pkg/job-queue/Doctrine/JobStorage.php @@ -58,13 +58,18 @@ public function findJobById($id) { $qb = $this->getEntityRepository()->createQueryBuilder('job'); - return $qb + $job = $qb ->addSelect('rootJob') ->leftJoin('job.rootJob', 'rootJob') ->where('job = :id') ->setParameter('id', $id) ->getQuery()->getOneOrNullResult() ; + if ($job) { + $this->refreshJobEntity($job); + } + + return $job; } /** @@ -179,6 +184,14 @@ public function saveJob(Job $job, \Closure $lockCallback = null) } } + /** + * @param Job $job + */ + public function refreshJobEntity($job) + { + $this->getEntityManager()->refresh($job); + } + /** * @return EntityRepository */