Skip to content

Commit

Permalink
No need to serialize this data before hand.
Browse files Browse the repository at this point in the history
  • Loading branch information
taylorotwell committed Feb 10, 2017
1 parent 8800252 commit 964fb7f
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
24 changes: 20 additions & 4 deletions src/Illuminate/Events/CallQueuedListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class CallQueuedListener implements ShouldQueue
/**
* The data to be passed to the listener.
*
* @var string
* @var array
*/
public $data;

Expand All @@ -37,7 +37,7 @@ class CallQueuedListener implements ShouldQueue
*
* @param string $class
* @param string $method
* @param string $data
* @param array $data
* @return void
*/
public function __construct($class, $method, $data)
Expand All @@ -55,12 +55,14 @@ public function __construct($class, $method, $data)
*/
public function handle(Container $container)
{
$this->prepareData();

$handler = $this->setJobInstanceIfNecessary(
$this->job, $container->make($this->class)
);

call_user_func_array(
[$handler, $this->method], unserialize($this->data)
[$handler, $this->method], $this->data
);
}

Expand Down Expand Up @@ -90,15 +92,29 @@ protected function setJobInstanceIfNecessary(Job $job, $instance)
*/
public function failed($e)
{
$this->prepareData();

$handler = Container::getInstance()->make($this->class);

$parameters = array_merge(unserialize($this->data), [$e]);
$parameters = array_merge($this->data, [$e]);

if (method_exists($handler, 'failed')) {
call_user_func_array([$handler, 'failed'], $parameters);
}
}

/**
* Unserialize the data if needed.
*
* @return void
*/
protected function prepareData()
{
if (is_string($this->data)) {
$this->data = unserialize($this->data);
}
}

/**
* Get the display name for the queued job.
*
Expand Down
2 changes: 1 addition & 1 deletion src/Illuminate/Events/Dispatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,7 @@ protected function queueHandler($class, $method, $arguments)

$this->resolveQueue()
->connection($connection)
->pushOn($queue, new CallQueuedListener($class, $method, serialize($arguments)));
->pushOn($queue, new CallQueuedListener($class, $method, $arguments));
}

/**
Expand Down

0 comments on commit 964fb7f

Please sign in to comment.