From 132bba6d2495a413ebafb444875e9638d801bafb Mon Sep 17 00:00:00 2001 From: David Maicher Date: Wed, 7 Feb 2018 20:03:36 +0100 Subject: [PATCH] [Cache][WebProfiler] fix collecting cache stats with sub-requests + allow clearing calls --- .../Component/Cache/Adapter/TraceableAdapter.php | 11 ++++++----- .../Cache/DataCollector/CacheDataCollector.php | 3 +-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Symfony/Component/Cache/Adapter/TraceableAdapter.php b/src/Symfony/Component/Cache/Adapter/TraceableAdapter.php index e8563521ba..98d0e52693 100644 --- a/src/Symfony/Component/Cache/Adapter/TraceableAdapter.php +++ b/src/Symfony/Component/Cache/Adapter/TraceableAdapter.php @@ -204,11 +204,12 @@ class TraceableAdapter implements AdapterInterface, PruneableInterface, Resettab public function getCalls() { - try { - return $this->calls; - } finally { - $this->calls = array(); - } + return $this->calls; + } + + public function clearCalls() + { + $this->calls = array(); } protected function start($name) diff --git a/src/Symfony/Component/Cache/DataCollector/CacheDataCollector.php b/src/Symfony/Component/Cache/DataCollector/CacheDataCollector.php index 62d502f01f..ceef45aa0b 100644 --- a/src/Symfony/Component/Cache/DataCollector/CacheDataCollector.php +++ b/src/Symfony/Component/Cache/DataCollector/CacheDataCollector.php @@ -57,8 +57,7 @@ class CacheDataCollector extends DataCollector implements LateDataCollectorInter { $this->data = array(); foreach ($this->instances as $instance) { - // Calling getCalls() will clear the calls. - $instance->getCalls(); + $instance->clearCalls(); } }