Merge pull request #24083 from owncloud/fix-race-condition

Read only once
This commit is contained in:
Jörn Friedrich Dreyer 2016-05-17 09:03:57 +02:00
commit 5e03e9a843
2 changed files with 4 additions and 2 deletions

View file

@ -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);

View file

@ -60,6 +60,7 @@ interface ICache {
* @param string $key
* @return bool
* @since 6.0.0
* @deprecated 9.1.0 Directly read from GET to prevent race conditions
*/
public function hasKey($key);