Skip to content

Commit

Permalink
formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
taylorotwell committed Dec 11, 2020
1 parent 2b566a5 commit f80f647
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 32 deletions.
8 changes: 0 additions & 8 deletions src/Illuminate/Contracts/Queue/UsesEncryption.php

This file was deleted.

39 changes: 20 additions & 19 deletions src/Illuminate/Queue/CallQueuedHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use Illuminate\Contracts\Bus\Dispatcher;
use Illuminate\Contracts\Cache\Repository as Cache;
use Illuminate\Contracts\Container\Container;
use Illuminate\Contracts\Encryption\Encrypter;
use Illuminate\Contracts\Queue\Job;
use Illuminate\Contracts\Queue\ShouldBeUnique;
use Illuminate\Contracts\Queue\ShouldBeUniqueUntilProcessing;
Expand Down Expand Up @@ -82,6 +83,25 @@ public function call(Job $job, array $data)
}
}

/**
* 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::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.
*
Expand Down Expand Up @@ -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.');
}
}
7 changes: 4 additions & 3 deletions src/Illuminate/Queue/Queue.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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, [
Expand Down
4 changes: 2 additions & 2 deletions tests/Integration/Queue/JobEncryptionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -93,7 +93,7 @@ public function testQueueCanProcessUnEncryptedJob()
}
}

class JobEncryptionTestEncryptedJob implements ShouldQueue, UsesEncryption
class JobEncryptionTestEncryptedJob implements ShouldQueue, ShouldBeEncrypted
{
use Dispatchable, Queueable;

Expand Down

0 comments on commit f80f647

Please sign in to comment.