Skip to content

Commit

Permalink
Merge pull request #842 from google/issue-821
Browse files Browse the repository at this point in the history
removes auth library caching
  • Loading branch information
bshaffer committed Feb 10, 2016
2 parents 5aa8760 + 19a4cbb commit fb16405
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 30 deletions.
22 changes: 5 additions & 17 deletions src/Google/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -929,25 +929,9 @@ public function setCache(CacheInterface $cache)
*/
public function getCache()
{
if (!isset($this->cache)) {
$this->cache = $this->createDefaultCache();
}

return $this->cache;
}

protected function createDefaultCache()
{
if ($this->isAppEngine()) {
$cache = new Google_Cache_Memcache();
} else {
$cacheDir = sys_get_temp_dir() . '/google-api-php-client';
$cache = new Google_Cache_File($cacheDir);
}

return $cache;
}

/**
* Set the Logger object
* @param Psr\Log\LoggerInterface $logger
Expand Down Expand Up @@ -1056,7 +1040,11 @@ private function createApplicationDefaultCredentials()

protected function getAuthHandler()
{
return Google_AuthHandler_AuthHandlerFactory::build($this->getCache());
// we intentionally do not use the cache because
// the underlying auth library's cache implementation
// is broken.
// @see https://github.com/google/google-api-php-client/issues/821
return Google_AuthHandler_AuthHandlerFactory::build();
}

private function createUserRefreshCredentials($scope, $refreshToken)
Expand Down
14 changes: 1 addition & 13 deletions tests/Google/ClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,7 @@ public function testSettersGetters()

$client->setRedirectUri('localhost');
$client->setConfig('application_name', 'me');
$client->setCache(new Google_Cache_Null());
$this->assertEquals('object', gettype($client->getCache()));

try {
Expand All @@ -268,19 +269,6 @@ public function testSettersGetters()
$this->assertEquals($token, $client->getAccessToken());
}

/**
* @requires extension Memcached
*/
public function testAppEngineMemcacheConfig()
{
$_SERVER['SERVER_SOFTWARE'] = 'Google App Engine';
$client = new Google_Client();

$this->assertInstanceOf('Google_Cache_Memcache', $client->getCache());

unset($_SERVER['SERVER_SOFTWARE']);
}

public function testAppEngineStreamHandlerConfig()
{
$this->onlyGuzzle5();
Expand Down

0 comments on commit fb16405

Please sign in to comment.