Skip to content

Commit 1900618

Browse files
authored
Use is_callable instead of method_exists to check for setup/teardown methods
`method_exists` will return true even if an object has a protected method; calling it from Resque will then fail. `is_callable` only returns true when the method both exists and can be called externally.
1 parent 968b7e6 commit 1900618

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

lib/Resque/Job.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -187,13 +187,13 @@ public function perform()
187187
Resque_Event::trigger('beforePerform', $this);
188188

189189
$instance = $this->getInstance();
190-
if(method_exists($instance, 'setUp')) {
190+
if(is_callable([$instance, 'setUp'])) {
191191
$instance->setUp();
192192
}
193193

194194
$instance->perform();
195195

196-
if(method_exists($instance, 'tearDown')) {
196+
if(is_callable([$instance, 'tearDown'])) {
197197
$instance->tearDown();
198198
}
199199

0 commit comments

Comments
 (0)