From 009eaf29fce6b7aa7cca07333218217ce64ef71f Mon Sep 17 00:00:00 2001 From: Xavier Leune Date: Mon, 26 Jan 2026 15:35:30 +0100 Subject: [PATCH 1/4] Worker mode: implement reset interface --- composer.json | 3 ++- .../DataCollector/TingCacheDataCollector.php | 9 +++++---- .../DataCollector/TingDriverDataCollector.php | 15 ++++++++------- 3 files changed, 15 insertions(+), 12 deletions(-) diff --git a/composer.json b/composer.json index d9773f5..0560fd9 100644 --- a/composer.json +++ b/composer.json @@ -11,7 +11,8 @@ "symfony/http-kernel": "^4.4 || ^5.0 || ^6.0", "symfony/dependency-injection": "^4.4 || ^5.0 || ^6.0", "symfony/config": "^4.4 || ^5.0 || ^6.0", - "symfony/stopwatch": "^4.4 || ^5.0 || ^6.0" + "symfony/stopwatch": "^4.4 || ^5.0 || ^6.0", + "symfony/contracts": "^2.5 || ^3.0" }, "require-dev": { "atoum/atoum": "^4.0", diff --git a/src/TingBundle/DataCollector/TingCacheDataCollector.php b/src/TingBundle/DataCollector/TingCacheDataCollector.php index 38b9568..9b69570 100644 --- a/src/TingBundle/DataCollector/TingCacheDataCollector.php +++ b/src/TingBundle/DataCollector/TingCacheDataCollector.php @@ -29,8 +29,9 @@ use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpKernel\DataCollector\DataCollector; use Symfony\Component\HttpKernel\DataCollector\LateDataCollectorInterface; +use Symfony\Contracts\Service\ResetInterface; -class TingCacheDataCollector extends DataCollector implements LateDataCollectorInterface +class TingCacheDataCollector extends DataCollector implements LateDataCollectorInterface, ResetInterface { /** * @var CacheLoggerInterface|null @@ -104,17 +105,17 @@ public function getCacheOperationsCount() public function getCacheTotalTime() { - return $this->data['cache']['time']; + return $this->data['cache']['time'] ?? 0; } public function getHits() { - return $this->data['cache']['hits']; + return $this->data['cache']['hits'] ?? 0; } public function getMiss() { - return $this->data['cache']['miss']; + return $this->data['cache']['miss'] ?? 0; } public function reset() diff --git a/src/TingBundle/DataCollector/TingDriverDataCollector.php b/src/TingBundle/DataCollector/TingDriverDataCollector.php index 268295c..35cc52c 100644 --- a/src/TingBundle/DataCollector/TingDriverDataCollector.php +++ b/src/TingBundle/DataCollector/TingDriverDataCollector.php @@ -29,8 +29,9 @@ use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpKernel\DataCollector\DataCollector; use Symfony\Component\HttpKernel\DataCollector\LateDataCollectorInterface; +use Symfony\Contracts\Service\ResetInterface; -class TingDriverDataCollector extends DataCollector implements LateDataCollectorInterface +class TingDriverDataCollector extends DataCollector implements LateDataCollectorInterface, ResetInterface { /** * @var DriverLoggerInterface|null @@ -116,32 +117,32 @@ public function setDriverLogger(DriverLoggerInterface $driverLogger = null) public function getQueryCount() { - return $this->data['driver']['queryCount']; + return $this->data['driver']['queryCount'] ?? 0; } public function getQueries() { - return $this->data['driver']['queries']; + return $this->data['driver']['queries'] ?? []; } public function getExecs() { - return $this->data['driver']['execs']; + return $this->data['driver']['execs'] ?? []; } public function getTime() { - return $this->data['driver']['time']; + return $this->data['driver']['time'] ?? 0; } public function getConnections() { - return $this->data['driver']['connections']; + return $this->data['driver']['connections'] ?? []; } public function getConnectionsHashToName() { - return $this->data['driver']['connectionsHashToName']; + return $this->data['driver']['connectionsHashToName'] ?? []; } public function reset() From 8a047a71ef9af7a2bde6b1638df7ad8602d082d9 Mon Sep 17 00:00:00 2001 From: Xavier Leune Date: Mon, 26 Jan 2026 18:01:30 +0100 Subject: [PATCH 2/4] Add kernel reset tags to Ting services --- src/TingBundle/Resources/config/services.xml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/TingBundle/Resources/config/services.xml b/src/TingBundle/Resources/config/services.xml index f3f0beb..691e6c0 100644 --- a/src/TingBundle/Resources/config/services.xml +++ b/src/TingBundle/Resources/config/services.xml @@ -42,12 +42,14 @@ %ting.database_options% + + @@ -79,10 +81,12 @@ + + From e8ce1d58d487bbad9b4d0a8253c7d87cfdb5131c Mon Sep 17 00:00:00 2001 From: Xavier Leune Date: Wed, 4 Feb 2026 11:59:28 +0100 Subject: [PATCH 3/4] Implement `ResetInterface` for loggers and update services configuration --- composer.json | 2 +- src/TingBundle/Logger/CacheLogger.php | 12 +++++++++++- src/TingBundle/Logger/DriverLogger.php | 14 +++++++++++++- src/TingBundle/Resources/config/services.xml | 1 + 4 files changed, 26 insertions(+), 3 deletions(-) diff --git a/composer.json b/composer.json index 0560fd9..2ff9ea2 100644 --- a/composer.json +++ b/composer.json @@ -12,7 +12,7 @@ "symfony/dependency-injection": "^4.4 || ^5.0 || ^6.0", "symfony/config": "^4.4 || ^5.0 || ^6.0", "symfony/stopwatch": "^4.4 || ^5.0 || ^6.0", - "symfony/contracts": "^2.5 || ^3.0" + "symfony/contracts": "^1.0 || ^2.0 || ^3.0" }, "require-dev": { "atoum/atoum": "^4.0", diff --git a/src/TingBundle/Logger/CacheLogger.php b/src/TingBundle/Logger/CacheLogger.php index e5b48fe..3443e3d 100644 --- a/src/TingBundle/Logger/CacheLogger.php +++ b/src/TingBundle/Logger/CacheLogger.php @@ -27,8 +27,9 @@ use CCMBenchmark\Ting\Logger\CacheLoggerInterface; use Psr\Log\LoggerInterface; use Symfony\Component\Stopwatch\Stopwatch; +use Symfony\Contracts\Service\ResetInterface; -class CacheLogger implements CacheLoggerInterface +class CacheLogger implements CacheLoggerInterface, ResetInterface { protected $operationIndex = 0; protected $operations = []; @@ -126,4 +127,13 @@ public function getMiss() { return $this->miss; } + + public function reset(): void + { + $this->operationIndex = 0; + $this->operations = []; + $this->hits = 0; + $this->miss = 0; + $this->totalTime = 0; + } } diff --git a/src/TingBundle/Logger/DriverLogger.php b/src/TingBundle/Logger/DriverLogger.php index 0e91424..3e98c8b 100644 --- a/src/TingBundle/Logger/DriverLogger.php +++ b/src/TingBundle/Logger/DriverLogger.php @@ -27,8 +27,9 @@ use CCMBenchmark\Ting\Logger\DriverLoggerInterface; use Psr\Log\LoggerInterface; use Symfony\Component\Stopwatch\Stopwatch; +use Symfony\Contracts\Service\ResetInterface; -class DriverLogger implements DriverLoggerInterface +class DriverLogger implements DriverLoggerInterface, ResetInterface { /** * @var null|LoggerInterface @@ -253,4 +254,15 @@ public function getExecs() { return $this->execs; } + + public function reset(): void + { + $this->queries = []; + $this->execs = []; + $this->totalTime = 0; + $this->connections = []; + $this->connectionsHashToName = []; + $this->queryIndex = 0; + $this->execIndex = 0; + } } diff --git a/src/TingBundle/Resources/config/services.xml b/src/TingBundle/Resources/config/services.xml index 691e6c0..5cb9aba 100644 --- a/src/TingBundle/Resources/config/services.xml +++ b/src/TingBundle/Resources/config/services.xml @@ -33,6 +33,7 @@ + From 112d72ff9bddb5c0d78eead52458f7581d6396bf Mon Sep 17 00:00:00 2001 From: Xavier Leune Date: Wed, 4 Feb 2026 13:49:33 +0100 Subject: [PATCH 4/4] use specific contracts --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 2ff9ea2..0279149 100644 --- a/composer.json +++ b/composer.json @@ -12,7 +12,7 @@ "symfony/dependency-injection": "^4.4 || ^5.0 || ^6.0", "symfony/config": "^4.4 || ^5.0 || ^6.0", "symfony/stopwatch": "^4.4 || ^5.0 || ^6.0", - "symfony/contracts": "^1.0 || ^2.0 || ^3.0" + "symfony/service-contracts": "^1.0 || ^2.0 || ^3.0" }, "require-dev": { "atoum/atoum": "^4.0",