@@ -31,8 +31,8 @@ abstract class JobBase extends \Tripod\Mongo\DriverBase
31
31
32
32
public function __construct ()
33
33
{
34
- \Resque_Event::listen ('beforePerform ' , [$ this , 'beforePerform ' ]);
35
- \Resque_Event::listen ('onFailure ' , [$ this , 'onFailure ' ]);
34
+ \Resque_Event::listen ('beforePerform ' , [self ::class , 'beforePerform ' ]);
35
+ \Resque_Event::listen ('onFailure ' , [self ::class , 'onFailure ' ]);
36
36
}
37
37
38
38
/**
@@ -63,7 +63,12 @@ abstract protected function getStatFailureIncrementKey();
63
63
*/
64
64
public static function beforePerform (\Resque_Job $ job )
65
65
{
66
- $ job ->getInstance ()->validateArgs ();
66
+ $ instance = $ job ->getInstance ();
67
+ if (!$ instance instanceof self) {
68
+ return ;
69
+ }
70
+
71
+ $ instance ->validateArgs ();
67
72
}
68
73
69
74
public function setUp ()
@@ -96,14 +101,17 @@ public function tearDown()
96
101
/**
97
102
* Resque event when a job failures
98
103
*
99
- * @param \Exception $e Exception
100
- * @param \Resque_Job $job The failed job
104
+ * @param \Throwable|\ Exception $e Exception or Error
105
+ * @param \Resque_Job $job The failed job
101
106
* @return void
102
107
*/
103
- public static function onFailure (\ Exception $ e , \Resque_Job $ job )
108
+ public static function onFailure ($ e , \Resque_Job $ job )
104
109
{
105
- /** @var JobBase $failedJob */
106
110
$ failedJob = $ job ->getInstance ();
111
+ if (!$ failedJob instanceof self) {
112
+ return ;
113
+ }
114
+
107
115
$ failedJob ->errorLog ('Caught exception in ' . get_called_class () . ': ' . $ e ->getMessage ());
108
116
$ failedJob ->getStat ()->increment ($ failedJob ->getStatFailureIncrementKey ());
109
117
throw $ e ;
0 commit comments