From fd0a556f5ca8893aad901a3fde82946e29cc2189 Mon Sep 17 00:00:00 2001 From: BVMiko Date: Tue, 23 May 2017 15:15:38 -0500 Subject: [PATCH] Fix issue with authentication issues with Stash Per PSR-6: > Hit - A cache hit occurs when a Calling Library requests an Item by key and a matching value is found for that key, and that value has not expired, and the value is not invalid for some other reason. Calling Libraries SHOULD make sure to verify isHit() on all get() calls. The $cacheItem response is never validated, and in the case of the Stash library the response contains the expired data (presumably to provide access to the previous cache). This should fix a recurring issue with authentication when using Stash for storing tokens; which were never being regenerated properly. There is one open issue https://github.com/google/google-api-php-client/issues/1075, plus several other closed issues which appear to have misdiagnosed the issue. --- src/CacheTrait.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/CacheTrait.php b/src/CacheTrait.php index 402249784..217ce8e2c 100644 --- a/src/CacheTrait.php +++ b/src/CacheTrait.php @@ -37,7 +37,9 @@ private function getCachedValue($k) } $cacheItem = $this->cache->getItem($key); - return $cacheItem->get(); + if ($cacheItem->isHit()) { + return $cacheItem->get(); + } } /**