Skip to content

Commit 224e625

Browse files
committed
fixes
1 parent 89aae32 commit 224e625

File tree

2 files changed

+6
-19
lines changed

2 files changed

+6
-19
lines changed

src/DependencyInjection/Compiler/DataCollectorCompilerPass.php

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -27,24 +27,9 @@ class DataCollectorCompilerPass extends BaseCompilerPass
2727
*/
2828
protected function prepare()
2929
{
30-
$this->transformLoggableCachePools();
31-
3230
$collectorDefinition = $this->container->getDefinition('data_collector.cache');
33-
3431
$serviceIds = $this->container->findTaggedServiceIds('cache.provider');
35-
foreach (array_keys($serviceIds) as $id) {
36-
$collectorDefinition->addMethodCall('addInstance', [$id, new Reference($id)]);
37-
}
38-
39-
$this->container->setDefinition('data_collector.cache', $collectorDefinition);
40-
}
4132

42-
/**
43-
* Make all cache providers loggable.
44-
*/
45-
private function transformLoggableCachePools()
46-
{
47-
$serviceIds = $this->container->findTaggedServiceIds('cache.provider');
4833
foreach (array_keys($serviceIds) as $id) {
4934

5035
// Duplicating definition to $originalServiceId.logged
@@ -56,6 +41,7 @@ private function transformLoggableCachePools()
5641

5742
// Overwrite the original service id with the new LoggingCachePool instance
5843
$this->container->setAlias($id, $id.'.logger');
44+
$collectorDefinition->addMethodCall('addInstance', [$id, new Reference($id.'.logger')]);
5945
}
6046
}
6147
}

src/Routing/Matcher/CacheUrlMatcher.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,14 +63,15 @@ public function match($pathInfo)
6363
$method = strtolower($this->context->getMethod());
6464
$key = 'route_'.$method.'_'.$host.'_'.$pathInfo;
6565

66-
if ($this->cachePool->hasItem($key)) {
67-
return $this->cachePool->getItem($key)->get();
66+
$cacheItem = $this->cachePool->getItem($key);
67+
if ($cacheItem->isHit()) {
68+
return $cacheItem->get();
6869
}
6970

7071
$match = parent::match($pathInfo);
71-
$item = $this->cachePool->getItem($key);
72-
$item->set($match)
72+
$cacheItem->set($match)
7373
->expiresAfter($this->ttl);
74+
$this->cachePool->save($cacheItem);
7475

7576
return $match;
7677
}

0 commit comments

Comments
 (0)