Changeset View
Changeset View
Standalone View
Standalone View
src/app/Jobs/GroupJob.php
Show First 20 Lines • Show All 52 Lines • ▼ Show 20 Lines | abstract class GroupJob extends CommonJob | ||||
* | * | ||||
* @throws \Exception | * @throws \Exception | ||||
*/ | */ | ||||
protected function getGroup() | protected function getGroup() | ||||
{ | { | ||||
$group = \App\Group::withTrashed()->find($this->groupId); | $group = \App\Group::withTrashed()->find($this->groupId); | ||||
if (!$group) { | if (!$group) { | ||||
// The record might not exist yet in case of a db replication environment | |||||
// This will release the job and delay another attempt for 5 seconds | |||||
if ($this instanceof Group\CreateJob) { | |||||
$this->release(5); | |||||
return null; | |||||
} | |||||
$this->fail(new \Exception("Group {$this->groupId} could not be found in the database.")); | $this->fail(new \Exception("Group {$this->groupId} could not be found in the database.")); | ||||
} | } | ||||
return $group; | return $group; | ||||
} | } | ||||
} | } |