diff options
author | Lukas Reschke <lukas@owncloud.com> | 2016-04-19 12:07:54 +0200 |
---|---|---|
committer | Lukas Reschke <lukas@owncloud.com> | 2016-05-02 11:31:57 +0200 |
commit | f81b57bc451d50555a2ed198127e6031f66c7031 (patch) | |
tree | 9fc41d733fae27381b4cd262f8361e7a90118206 /lib/private/Route | |
parent | 5a62c74495e489995f64be5b86e42927f57863f7 (diff) | |
download | nextcloud-server-f81b57bc451d50555a2ed198127e6031f66c7031.tar.gz nextcloud-server-f81b57bc451d50555a2ed198127e6031f66c7031.zip |
Read only once
This can lead to race conditions otherwise. Also depracted hasKey
Diffstat (limited to 'lib/private/Route')
-rw-r--r-- | lib/private/Route/CachingRouter.php | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/lib/private/Route/CachingRouter.php b/lib/private/Route/CachingRouter.php index d6270dcf2c7..063d389e98b 100644 --- a/lib/private/Route/CachingRouter.php +++ b/lib/private/Route/CachingRouter.php @@ -50,8 +50,9 @@ class CachingRouter extends Router { public function generate($name, $parameters = array(), $absolute = false) { asort($parameters); $key = $this->context->getHost() . '#' . $this->context->getBaseUrl() . $name . sha1(json_encode($parameters)) . intval($absolute); - if ($this->cache->hasKey($key)) { - return $this->cache->get($key); + $cachedKey = $this->cache->get($key); + if ($cachedKey) { + return $cachedKey; } else { $url = parent::generate($name, $parameters, $absolute); $this->cache->set($key, $url, 3600); |