mirror of
https://github.com/idanoo/php-resque.git
synced 2024-11-22 08:15:14 +00:00
when reserving jobs, check if the payload received from popping a queue is a valid object (fix bug whereby jobs are reserved based on an erroneous payload)
This commit is contained in:
parent
45c49cf002
commit
68df9854a6
@ -27,7 +27,7 @@ class Resque_Job
|
|||||||
* @var object Object containing details of the job.
|
* @var object Object containing details of the job.
|
||||||
*/
|
*/
|
||||||
public $payload;
|
public $payload;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var object Instance of the class performing work for this job.
|
* @var object Instance of the class performing work for this job.
|
||||||
*/
|
*/
|
||||||
@ -84,7 +84,7 @@ class Resque_Job
|
|||||||
public static function reserve($queue)
|
public static function reserve($queue)
|
||||||
{
|
{
|
||||||
$payload = Resque::pop($queue);
|
$payload = Resque::pop($queue);
|
||||||
if(!$payload) {
|
if(!is_object($payload)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -116,7 +116,7 @@ class Resque_Job
|
|||||||
$status = new Resque_Job_Status($this->payload['id']);
|
$status = new Resque_Job_Status($this->payload['id']);
|
||||||
return $status->get();
|
return $status->get();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the arguments supplied to this job.
|
* Get the arguments supplied to this job.
|
||||||
*
|
*
|
||||||
@ -127,10 +127,10 @@ class Resque_Job
|
|||||||
if (!isset($this->payload['args'])) {
|
if (!isset($this->payload['args'])) {
|
||||||
return array();
|
return array();
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->payload['args'][0];
|
return $this->payload['args'][0];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the instantiated object for this job that will be performing work.
|
* Get the instantiated object for this job that will be performing work.
|
||||||
*
|
*
|
||||||
@ -171,7 +171,7 @@ class Resque_Job
|
|||||||
$instance = $this->getInstance();
|
$instance = $this->getInstance();
|
||||||
try {
|
try {
|
||||||
Resque_Event::trigger('beforePerform', $this);
|
Resque_Event::trigger('beforePerform', $this);
|
||||||
|
|
||||||
if(method_exists($instance, 'setUp')) {
|
if(method_exists($instance, 'setUp')) {
|
||||||
$instance->setUp();
|
$instance->setUp();
|
||||||
}
|
}
|
||||||
@ -188,7 +188,7 @@ class Resque_Job
|
|||||||
catch(Resque_Job_DontPerform $e) {
|
catch(Resque_Job_DontPerform $e) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user