Skip to content

Commit

Permalink
Fix issue with authentication issues with Stash
Browse files Browse the repository at this point in the history
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 googleapis/google-api-php-client#1075, plus several other closed issues which appear to have misdiagnosed the issue.
  • Loading branch information
BVMiko authored May 23, 2017
1 parent 33bc708 commit fd0a556
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/CacheTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ private function getCachedValue($k)
}

$cacheItem = $this->cache->getItem($key);
return $cacheItem->get();
if ($cacheItem->isHit()) {
return $cacheItem->get();
}
}

/**
Expand Down

0 comments on commit fd0a556

Please sign in to comment.