Changeset View
Changeset View
Standalone View
Standalone View
src/app/Jobs/UserJob.php
Show First 20 Lines • Show All 52 Lines • ▼ Show 20 Lines | abstract class UserJob extends CommonJob | ||||
* | * | ||||
* @throws \Exception | * @throws \Exception | ||||
*/ | */ | ||||
protected function getUser() | protected function getUser() | ||||
{ | { | ||||
$user = \App\User::withTrashed()->find($this->userId); | $user = \App\User::withTrashed()->find($this->userId); | ||||
if (!$user) { | if (!$user) { | ||||
// 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 User\CreateJob) { | |||||
$this->release(5); | |||||
return null; | |||||
} | |||||
$this->fail(new \Exception("User {$this->userId} could not be found in the database.")); | $this->fail(new \Exception("User {$this->userId} could not be found in the database.")); | ||||
} | } | ||||
return $user; | return $user; | ||||
} | } | ||||
} | } |