Browse Source

Read only once

This can lead to race conditions otherwise. Also depracted hasKey
remotes/origin/ceph-wait-for-http
Lukas Reschke 10 years ago
parent
commit
f81b57bc45
No known key found for this signature in database GPG Key ID: 9AB0ADB949B6898C
  1. 5
      lib/private/Route/CachingRouter.php
  2. 1
      lib/public/icache.php

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

1
lib/public/icache.php

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

Loading…
Cancel
Save