From c9d7a69ecbc28dcc6660cb35322800b5c6d61eff Mon Sep 17 00:00:00 2001 From: Graham Campbell Date: Fri, 16 Aug 2019 17:14:18 +0100 Subject: [PATCH 1/3] Fixed incorrect implementation of PSR-16 --- src/Illuminate/Cache/Repository.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Illuminate/Cache/Repository.php b/src/Illuminate/Cache/Repository.php index 5a2757e97dc7..bbf6007154eb 100755 --- a/src/Illuminate/Cache/Repository.php +++ b/src/Illuminate/Cache/Repository.php @@ -199,7 +199,7 @@ public function put($key, $value, $minutes = null) */ public function set($key, $value, $ttl = null) { - $this->put($key, $value, $ttl); + $this->put($key, $value, $ttl === null ? null : $ttl / 60); } /** @@ -225,7 +225,7 @@ public function putMany(array $values, $minutes) */ public function setMultiple($values, $ttl = null) { - $this->putMany(is_array($values) ? $values : iterator_to_array($values), $ttl); + $this->putMany(is_array($values) ? $values : iterator_to_array($values), $ttl === null ? null : $ttl / 60); } /** From 1663d7442e842906704532b2569ca4babb44f6b4 Mon Sep 17 00:00:00 2001 From: Graham Campbell Date: Fri, 16 Aug 2019 17:25:59 +0100 Subject: [PATCH 2/3] TTL could be a DateInterval --- src/Illuminate/Cache/Repository.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Illuminate/Cache/Repository.php b/src/Illuminate/Cache/Repository.php index bbf6007154eb..075a54a91742 100755 --- a/src/Illuminate/Cache/Repository.php +++ b/src/Illuminate/Cache/Repository.php @@ -199,7 +199,7 @@ public function put($key, $value, $minutes = null) */ public function set($key, $value, $ttl = null) { - $this->put($key, $value, $ttl === null ? null : $ttl / 60); + $this->put($key, $value, is_int($ttl) ? $ttl / 60 : null); } /** @@ -225,7 +225,7 @@ public function putMany(array $values, $minutes) */ public function setMultiple($values, $ttl = null) { - $this->putMany(is_array($values) ? $values : iterator_to_array($values), $ttl === null ? null : $ttl / 60); + $this->putMany(is_array($values) ? $values : iterator_to_array($values), is_int($ttl) ? $ttl / 60 : null); } /** From e14e4d7fd105386ea37a6c9d62f6b07a46abe62b Mon Sep 17 00:00:00 2001 From: Graham Campbell Date: Fri, 16 Aug 2019 23:48:13 +0100 Subject: [PATCH 3/3] Fixed cache tests --- tests/Cache/CacheRepositoryTest.php | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/tests/Cache/CacheRepositoryTest.php b/tests/Cache/CacheRepositoryTest.php index 4710710aa5d4..a275f310d1ad 100755 --- a/tests/Cache/CacheRepositoryTest.php +++ b/tests/Cache/CacheRepositoryTest.php @@ -116,18 +116,16 @@ public function testPuttingMultipleItemsInCache() public function testSettingMultipleItemsInCacheArray() { - // Alias of PuttingMultiple $repo = $this->getRepository(); $repo->getStore()->shouldReceive('putMany')->once()->with(['foo' => 'bar', 'bar' => 'baz'], 1); - $repo->setMultiple(['foo' => 'bar', 'bar' => 'baz'], 1); + $repo->setMultiple(['foo' => 'bar', 'bar' => 'baz'], 60); } public function testSettingMultipleItemsInCacheIterator() { - // Alias of PuttingMultiple $repo = $this->getRepository(); $repo->getStore()->shouldReceive('putMany')->once()->with(['foo' => 'bar', 'bar' => 'baz'], 1); - $repo->setMultiple(new ArrayIterator(['foo' => 'bar', 'bar' => 'baz']), 1); + $repo->setMultiple(new ArrayIterator(['foo' => 'bar', 'bar' => 'baz']), 60); } public function testPutWithDatetimeInPastOrZeroSecondsDoesntSaveItem() @@ -210,7 +208,7 @@ public function testSettingCache() { $repo = $this->getRepository(); $repo->getStore()->shouldReceive('put')->with($key = 'foo', $value = 'bar', 1); - $repo->set($key, $value, 1); + $repo->set($key, $value, 60); } public function testClearingWholeCache()