Skip to content

Commit

Permalink
when reserving jobs, check if the payload received from popping a que…
Browse files Browse the repository at this point in the history
…ue is a valid object (fix bug whereby jobs are reserved based on an erroneous payload)
  • Loading branch information
Salimane Adjao Moustapha committed Dec 7, 2011
1 parent 45c49cf commit 68df985
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions lib/Resque/Job.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class Resque_Job
* @var object Object containing details of the job.
*/
public $payload;

/**
* @var object Instance of the class performing work for this job.
*/
Expand Down Expand Up @@ -84,7 +84,7 @@ public static function create($queue, $class, $args = null, $monitor = false)
public static function reserve($queue)
{
$payload = Resque::pop($queue);
if(!$payload) {
if(!is_object($payload)) {
return false;
}

Expand Down Expand Up @@ -116,7 +116,7 @@ public function getStatus()
$status = new Resque_Job_Status($this->payload['id']);
return $status->get();
}

/**
* Get the arguments supplied to this job.
*
Expand All @@ -127,10 +127,10 @@ public function getArguments()
if (!isset($this->payload['args'])) {
return array();
}

return $this->payload['args'][0];
}

/**
* Get the instantiated object for this job that will be performing work.
*
Expand Down Expand Up @@ -171,7 +171,7 @@ public function perform()
$instance = $this->getInstance();
try {
Resque_Event::trigger('beforePerform', $this);

if(method_exists($instance, 'setUp')) {
$instance->setUp();
}
Expand All @@ -188,7 +188,7 @@ public function perform()
catch(Resque_Job_DontPerform $e) {
return false;
}

return true;
}

Expand Down

0 comments on commit 68df985

Please sign in to comment.