From 9c20e44483b3915a06106c32fc4db2d6dc58b40d Mon Sep 17 00:00:00 2001 From: Takuya Sato Date: Wed, 26 Aug 2015 10:26:48 +0900 Subject: [PATCH] return false if `json_encode()` failed. --- lib/Resque.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/Resque.php b/lib/Resque.php index 4729189..5d93375 100644 --- a/lib/Resque.php +++ b/lib/Resque.php @@ -101,8 +101,12 @@ class Resque */ public static function push($queue, $item) { + $encodedItem = json_encode($item); + if ($encodedItem === false) { + return false; + } self::redis()->sadd('queues', $queue); - $length = self::redis()->rpush('queue:' . $queue, json_encode($item)); + $length = self::redis()->rpush('queue:' . $queue, $encodedItem); if ($length < 1) { return false; }