From d6a29c1399e04b72f9100f93f4a37673ef498573 Mon Sep 17 00:00:00 2001 From: Brent Shaffer Date: Tue, 9 Feb 2016 15:55:54 -0800 Subject: [PATCH 1/2] removes auth library caching --- src/Google/Client.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Google/Client.php b/src/Google/Client.php index 462c6b0f8..aa2256c93 100644 --- a/src/Google/Client.php +++ b/src/Google/Client.php @@ -1056,7 +1056,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) From 19a4cbb33393ae8978663a390aa8e41529f586cf Mon Sep 17 00:00:00 2001 From: Brent Shaffer Date: Wed, 10 Feb 2016 13:01:44 -0800 Subject: [PATCH 2/2] removes createDefaultCache method and fixes tests --- src/Google/Client.php | 16 ---------------- tests/Google/ClientTest.php | 14 +------------- 2 files changed, 1 insertion(+), 29 deletions(-) diff --git a/src/Google/Client.php b/src/Google/Client.php index aa2256c93..c9ac53546 100644 --- a/src/Google/Client.php +++ b/src/Google/Client.php @@ -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 diff --git a/tests/Google/ClientTest.php b/tests/Google/ClientTest.php index 0ab3a6aec..8369b4eb0 100644 --- a/tests/Google/ClientTest.php +++ b/tests/Google/ClientTest.php @@ -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 { @@ -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();