From f80f647852106942e4a0ef3e9963f8f7a99122cf Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Fri, 11 Dec 2020 08:34:10 -0600 Subject: [PATCH] formatting --- .../Contracts/Queue/UsesEncryption.php | 8 ---- src/Illuminate/Queue/CallQueuedHandler.php | 39 ++++++++++--------- src/Illuminate/Queue/Queue.php | 7 ++-- tests/Integration/Queue/JobEncryptionTest.php | 4 +- 4 files changed, 26 insertions(+), 32 deletions(-) delete mode 100644 src/Illuminate/Contracts/Queue/UsesEncryption.php diff --git a/src/Illuminate/Contracts/Queue/UsesEncryption.php b/src/Illuminate/Contracts/Queue/UsesEncryption.php deleted file mode 100644 index 2e3a6560b1cd..000000000000 --- a/src/Illuminate/Contracts/Queue/UsesEncryption.php +++ /dev/null @@ -1,8 +0,0 @@ -container->bound(Encrypter::class)) { + return unserialize($this->container[Encrypter::class]->decrypt($data['command'])); + } + + throw new RuntimeException('Unable to extract job payload.'); + } + /** * Dispatch the given job / command through its specified middleware. * @@ -274,23 +294,4 @@ protected function ensureChainCatchCallbacksAreInvoked(string $uuid, $command, $ $command->invokeChainCatchCallbacks($e); } } - - /** - * Get the command from the given payload. - * - * @param array $data - * @return mixed - */ - protected function getCommand(array $data) - { - if (Str::startsWith($data['command'], 'O:')) { - return unserialize($data['command']); - } - - if ($this->container->bound('encrypter')) { - return unserialize($this->container['encrypter']->decrypt($data['command'])); - } - - throw new RuntimeException('Unable to extract job payload.'); - } } diff --git a/src/Illuminate/Queue/Queue.php b/src/Illuminate/Queue/Queue.php index bce224d646e3..b22ed51cd446 100755 --- a/src/Illuminate/Queue/Queue.php +++ b/src/Illuminate/Queue/Queue.php @@ -5,7 +5,8 @@ use Closure; use DateTimeInterface; use Illuminate\Container\Container; -use Illuminate\Contracts\Queue\UsesEncryption; +use Illuminate\Contracts\Encryption\Encrypter; +use Illuminate\Contracts\Queue\ShouldBeEncrypted; use Illuminate\Support\Arr; use Illuminate\Support\InteractsWithTime; use Illuminate\Support\Str; @@ -150,8 +151,8 @@ protected function createObjectPayload($job, $queue) ], ]); - $command = $job instanceof UsesEncryption && $this->container->bound('encrypter') - ? $this->container['encrypter']->encrypt(serialize(clone $job)) + $command = $job instanceof ShouldBeEncrypted && $this->container->bound(Encrypter::class) + ? $this->container[Encrypter::class]->encrypt(serialize(clone $job)) : serialize(clone $job); return array_merge($payload, [ diff --git a/tests/Integration/Queue/JobEncryptionTest.php b/tests/Integration/Queue/JobEncryptionTest.php index fb331e7394ff..e10124094661 100644 --- a/tests/Integration/Queue/JobEncryptionTest.php +++ b/tests/Integration/Queue/JobEncryptionTest.php @@ -4,7 +4,7 @@ use Illuminate\Bus\Queueable; use Illuminate\Contracts\Queue\ShouldQueue; -use Illuminate\Contracts\Queue\UsesEncryption; +use Illuminate\Contracts\Queue\ShouldBeEncrypted; use Illuminate\Database\Schema\Blueprint; use Illuminate\Foundation\Bus\Dispatchable; use Illuminate\Support\Facades\Bus; @@ -93,7 +93,7 @@ public function testQueueCanProcessUnEncryptedJob() } } -class JobEncryptionTestEncryptedJob implements ShouldQueue, UsesEncryption +class JobEncryptionTestEncryptedJob implements ShouldQueue, ShouldBeEncrypted { use Dispatchable, Queueable;