From 19006186289800e98fd4bdcbad803d9657f27808 Mon Sep 17 00:00:00 2001 From: Ben Morris Date: Wed, 3 Jan 2018 16:51:46 -0800 Subject: [PATCH] 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. --- lib/Resque/Job.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/Resque/Job.php b/lib/Resque/Job.php index 8508f766..f12fd82a 100755 --- a/lib/Resque/Job.php +++ b/lib/Resque/Job.php @@ -187,13 +187,13 @@ public function perform() Resque_Event::trigger('beforePerform', $this); $instance = $this->getInstance(); - if(method_exists($instance, 'setUp')) { + if(is_callable([$instance, 'setUp'])) { $instance->setUp(); } $instance->perform(); - if(method_exists($instance, 'tearDown')) { + if(is_callable([$instance, 'tearDown'])) { $instance->tearDown(); }