diff --git a/src/Illuminate/Cache/RedisStore.php b/src/Illuminate/Cache/RedisStore.php index 6c7b30b77f97..100af0d32f4b 100755 --- a/src/Illuminate/Cache/RedisStore.php +++ b/src/Illuminate/Cache/RedisStore.php @@ -73,7 +73,7 @@ public function many(array $keys) }, $keys)); foreach ($values as $index => $value) { - $results[$keys[$index]] = $this->unserialize($value); + $results[$keys[$index]] = ! is_null($value) ? $this->unserialize($value) : null; } return $results; diff --git a/tests/Cache/CacheRedisStoreTest.php b/tests/Cache/CacheRedisStoreTest.php index b688dae2ec6d..ce5571823589 100755 --- a/tests/Cache/CacheRedisStoreTest.php +++ b/tests/Cache/CacheRedisStoreTest.php @@ -32,19 +32,20 @@ public function testRedisMultipleValuesAreReturned() { $redis = $this->getRedis(); $redis->getRedis()->shouldReceive('connection')->once()->with('default')->andReturn($redis->getRedis()); - $redis->getRedis()->shouldReceive('mget')->once()->with(['prefix:foo', 'prefix:fizz', 'prefix:norf']) + $redis->getRedis()->shouldReceive('mget')->once()->with(['prefix:foo', 'prefix:fizz', 'prefix:norf', 'prefix:null']) ->andReturn([ serialize('bar'), serialize('buzz'), serialize('quz'), + null, ]); - $this->assertEquals([ - 'foo' => 'bar', - 'fizz' => 'buzz', - 'norf' => 'quz', - ], $redis->many([ - 'foo', 'fizz', 'norf', - ])); + + $results = $redis->many(['foo', 'fizz', 'norf', 'null']); + + $this->assertEquals('bar', $results['foo']); + $this->assertEquals('buzz', $results['fizz']); + $this->assertEquals('quz', $results['norf']); + $this->assertNull($results['null']); } public function testRedisValueIsReturnedForNumerics()