summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwebchick2013-01-20 04:13:58 (GMT)
committerwebchick2013-01-20 04:13:58 (GMT)
commitf4d2f16f3d33ccef131f40f827317d83aade4d2b (patch)
treee2951079e9fa3509dffeda079ac47c556545a024
parent956b110a1e2440676452760250b634185b9afefc (diff)
Issue #1891692 by katbailey: Fixed AliasManagerCacheDecorator won't work correctly with subrequests.
-rw-r--r--core/lib/Drupal/Core/CacheDecorator/AliasManagerCacheDecorator.php16
-rw-r--r--core/lib/Drupal/Core/EventSubscriber/PathSubscriber.php7
2 files changed, 12 insertions, 11 deletions
diff --git a/core/lib/Drupal/Core/CacheDecorator/AliasManagerCacheDecorator.php b/core/lib/Drupal/Core/CacheDecorator/AliasManagerCacheDecorator.php
index ae5c8bc..01264c2 100644
--- a/core/lib/Drupal/Core/CacheDecorator/AliasManagerCacheDecorator.php
+++ b/core/lib/Drupal/Core/CacheDecorator/AliasManagerCacheDecorator.php
@@ -26,11 +26,11 @@ class AliasManagerCacheDecorator implements CacheDecoratorInterface, AliasManage
protected $cache;
/**
- * Stack of request paths for use as cids when caching system paths.
+ * The cache key to use when caching system paths.
*
- * @var array
+ * @var string
*/
- protected $cacheKeys = array();
+ protected $cacheKey;
/**
* Holds an array of previously cached paths based on a request path.
@@ -58,7 +58,7 @@ class AliasManagerCacheDecorator implements CacheDecoratorInterface, AliasManage
* Implements \Drupal\Core\CacheDecorator\CacheDecoratorInterface::setCacheKey().
*/
public function setCacheKey($key) {
- $this->cacheKeys[] = $key;
+ $this->cacheKey = $key;
}
/**
@@ -73,15 +73,11 @@ class AliasManagerCacheDecorator implements CacheDecoratorInterface, AliasManage
$path_lookups = $this->getPathLookups();
// Check if the system paths for this page were loaded from cache in this
// request to avoid writing to cache on every request.
- if ($this->cacheNeedsWriting && !empty($path_lookups) && !empty($this->cacheKeys)) {
- // Use the system path of the current request for the cache ID (cid).
- $cid = end($this->cacheKeys);
+ if ($this->cacheNeedsWriting && !empty($path_lookups) && !empty($this->cacheKey)) {
// Set the path cache to expire in 24 hours.
$expire = REQUEST_TIME + (60 * 60 * 24);
- $this->cache->set($cid, $path_lookups, $expire);
+ $this->cache->set($this->cacheKey, $path_lookups, $expire);
}
- // We are at the end of the request, so pop off the last request path.
- array_pop($this->cacheKeys);
}
/**
diff --git a/core/lib/Drupal/Core/EventSubscriber/PathSubscriber.php b/core/lib/Drupal/Core/EventSubscriber/PathSubscriber.php
index 8f0359d..be0e779 100644
--- a/core/lib/Drupal/Core/EventSubscriber/PathSubscriber.php
+++ b/core/lib/Drupal/Core/EventSubscriber/PathSubscriber.php
@@ -8,6 +8,7 @@
namespace Drupal\Core\EventSubscriber;
use Drupal\Core\CacheDecorator\AliasManagerCacheDecorator;
+use Symfony\Component\HttpKernel\HttpKernelInterface;
use Symfony\Component\HttpKernel\KernelEvents;
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
use Symfony\Component\HttpKernel\Event\PostResponseEvent;
@@ -35,7 +36,11 @@ class PathSubscriber extends PathListenerBase implements EventSubscriberInterfac
$path = $this->extractPath($request);
$path = $this->aliasManager->getSystemPath($path);
$this->setPath($request, $path);
- $this->aliasManager->setCacheKey($path);
+ // If this is the master request, set the cache key for the caching of all
+ // system paths looked up during the request.
+ if ($event->getRequestType() == HttpKernelInterface::MASTER_REQUEST) {
+ $this->aliasManager->setCacheKey($path);
+ }
}
/**