Skip to content

Commit dd8c10f

Browse files
committed
fix: Only load job after persisting to prevent UnknownObjectException
1 parent 5d4757a commit dd8c10f

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

Classes/Job/Workspace/Publish.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use Flowpack\JobQueue\Common\Queue\Message;
88
use Flowpack\JobQueue\Common\Queue\QueueInterface;
99
use GuzzleHttp\Psr7\Uri;
10+
use InvalidArgumentException;
1011
use Neos\ContentRepository\Domain\Repository\WorkspaceRepository;
1112
use Neos\Flow\Annotations as Flow;
1213
use Neos\Flow\I18n\Translator;
@@ -121,17 +122,15 @@ public function injectControllerContextFactory(ControllerContextFactory $control
121122

122123
public function execute(QueueInterface $queue, Message $message): bool
123124
{
124-
$job = $this->jobRepository->findByIdentifier($this->jobIdentifier);
125-
if (!$job instanceof Job) {
126-
throw new \InvalidArgumentException(sprintf('No job with identifier "%s" found', $this->jobIdentifier),
125+
if (!$this->jobRepository->findByIdentifier($this->jobIdentifier) instanceof Job) {
126+
throw new InvalidArgumentException(
127+
sprintf('No job with identifier "%s" found', $this->jobIdentifier),
127128
1660661997);
128129
}
129130

130131
try {
131132
$this->publish();
132133
} catch (\Throwable $t) {
133-
$job->setStatus(Job::STATUS_DONE);
134-
135134
$error = new Error();
136135
$error->setMessage($t->getMessage());
137136

@@ -143,6 +142,7 @@ public function execute(QueueInterface $queue, Message $message): bool
143142
);
144143
$this->feedbackCollection->setControllerContext($controllerContext);
145144

145+
$job = $this->jobRepository->findByIdentifier($this->jobIdentifier);
146146
$job->setFeedback($this->feedbackCollection->jsonSerialize());
147147
$job->setStatus(Job::STATUS_DONE);
148148
$this->jobRepository->update($job);

0 commit comments

Comments
 (0)