diff --git a/src/Illuminate/Contracts/Queue/UniqueJob.php b/src/Illuminate/Contracts/Queue/UniqueJob.php deleted file mode 100644 index 603be95f5d42..000000000000 --- a/src/Illuminate/Contracts/Queue/UniqueJob.php +++ /dev/null @@ -1,8 +0,0 @@ -job instanceof UniqueJob)) { + if (! method_exists($this->job, 'uniqueId') + && ! property_exists($this->job, 'uniqueId')) { return true; } diff --git a/src/Illuminate/Foundation/Console/stubs/job.queued.stub b/src/Illuminate/Foundation/Console/stubs/job.queued.stub index 0be12826fb73..5f0651cb1789 100644 --- a/src/Illuminate/Foundation/Console/stubs/job.queued.stub +++ b/src/Illuminate/Foundation/Console/stubs/job.queued.stub @@ -4,7 +4,6 @@ namespace {{ namespace }}; use Illuminate\Bus\Queueable; use Illuminate\Contracts\Queue\ShouldQueue; -use Illuminate\Contracts\Queue\UniqueJob; use Illuminate\Foundation\Bus\Dispatchable; use Illuminate\Queue\InteractsWithQueue; use Illuminate\Queue\SerializesModels; diff --git a/src/Illuminate/Queue/CallQueuedHandler.php b/src/Illuminate/Queue/CallQueuedHandler.php index ec3bfa48ea27..a3a653af25f8 100644 --- a/src/Illuminate/Queue/CallQueuedHandler.php +++ b/src/Illuminate/Queue/CallQueuedHandler.php @@ -8,7 +8,6 @@ use Illuminate\Contracts\Cache\Repository as Cache; use Illuminate\Contracts\Container\Container; use Illuminate\Contracts\Queue\Job; -use Illuminate\Contracts\Queue\UniqueJob; use Illuminate\Database\Eloquent\ModelNotFoundException; use Illuminate\Pipeline\Pipeline; use ReflectionClass; @@ -167,7 +166,8 @@ protected function ensureSuccessfulBatchJobIsRecorded($command) */ protected function ensureUniqueJobLockIsReleased($command) { - if ($command instanceof UniqueJob) { + if (method_exists($command, 'uniqueId') + || property_exists($command, 'uniqueId')) { $uniqueId = method_exists($command, 'uniqueId') ? $command->uniqueId() : ($command->uniqueId ?? ''); diff --git a/tests/Integration/Queue/UniqueJobTest.php b/tests/Integration/Queue/UniqueJobTest.php index 45c09338ae40..8335e59199f7 100644 --- a/tests/Integration/Queue/UniqueJobTest.php +++ b/tests/Integration/Queue/UniqueJobTest.php @@ -5,7 +5,6 @@ use Illuminate\Bus\Queueable; use Illuminate\Contracts\Cache\Repository as Cache; use Illuminate\Contracts\Queue\ShouldQueue; -use Illuminate\Contracts\Queue\UniqueJob; use Illuminate\Database\Schema\Blueprint; use Illuminate\Foundation\Bus\Dispatchable; use Illuminate\Queue\InteractsWithQueue; @@ -146,24 +145,28 @@ protected function getLockKey($job) } } -class UniqueTestJob implements ShouldQueue, UniqueJob +class UniqueTestJob implements ShouldQueue { use InteractsWithQueue, Queueable, Dispatchable; public static $handled = false; + public $uniqueId = ''; + public function handle() { static::$handled = true; } } -class UniqueTestFailJob implements ShouldQueue, UniqueJob +class UniqueTestFailJob implements ShouldQueue { use InteractsWithQueue, Queueable, Dispatchable; public $tries = 1; + public $uniqueId = ''; + public static $handled = false; public function handle()