@@ -131,18 +131,22 @@ public function updateStatus($status, $result = null)
131131 return ;
132132 }
133133
134- $ statusInstance = new Resque_Job_Status ($ this ->payload ['id ' ], $ this ->payload [ ' prefix ' ] );
134+ $ statusInstance = new Resque_Job_Status ($ this ->payload ['id ' ], $ this ->getPrefix () );
135135 $ statusInstance ->update ($ status , $ result );
136136 }
137137
138138 /**
139139 * Return the status of the current job.
140140 *
141- * @return int The status of the job as one of the Resque_Job_Status constants.
141+ * @return int|null The status of the job as one of the Resque_Job_Status constants or null if job is not being tracked .
142142 */
143143 public function getStatus ()
144144 {
145- $ status = new Resque_Job_Status ($ this ->payload ['id ' ], $ this ->payload ['prefix ' ]);
145+ if (empty ($ this ->payload ['id ' ])) {
146+ return null ;
147+ }
148+
149+ $ status = new Resque_Job_Status ($ this ->payload ['id ' ], $ this ->getPrefix ());
146150 return $ status ->get ();
147151 }
148152
@@ -248,13 +252,15 @@ public function fail($exception)
248252 */
249253 public function recreate ()
250254 {
251- $ status = new Resque_Job_Status ($ this ->payload ['id ' ], $ this ->payload ['prefix ' ]);
252255 $ monitor = false ;
253- if ($ status ->isTracking ()) {
254- $ monitor = true ;
256+ if (isset ($ this ->payload ['id ' ])) {
257+ $ status = new Resque_Job_Status ($ this ->payload ['id ' ], $ this ->getPrefix ());
258+ if ($ status ->isTracking ()) {
259+ $ monitor = true ;
260+ }
255261 }
256262
257- return self ::create ($ this ->queue , $ this ->payload ['class ' ], $ this ->getArguments (), $ monitor , $ this ->payload [ ' prefix ' ] );
263+ return self ::create ($ this ->queue , $ this ->payload ['class ' ], $ this ->getArguments (), $ monitor , null , $ this ->getPrefix () );
258264 }
259265
260266 /**
@@ -298,4 +304,16 @@ public function getJobFactory()
298304 }
299305 return $ this ->jobFactory ;
300306 }
307+
308+ /**
309+ * @return string
310+ */
311+ private function getPrefix ()
312+ {
313+ if (isset ($ this ->payload ['prefix ' ])) {
314+ return $ this ->payload ['prefix ' ];
315+ }
316+
317+ return '' ;
318+ }
301319}
0 commit comments