From e5ee1e6eaf833482b7d6a97d8d289cc2163f189b Mon Sep 17 00:00:00 2001 From: Matthias Vogel Date: Thu, 14 Sep 2023 12:31:57 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20fix=20middleware.in.total=20mult?= =?UTF-8?q?iple=20times=20called?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Classes/Middleware/WrapMiddleware.php | 2 +- Classes/Middleware/XClassMiddlewareDispatcher.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Classes/Middleware/WrapMiddleware.php b/Classes/Middleware/WrapMiddleware.php index b024a4c..d4eb330 100644 --- a/Classes/Middleware/WrapMiddleware.php +++ b/Classes/Middleware/WrapMiddleware.php @@ -36,7 +36,7 @@ public function handle(ServerRequestInterface $request): ResponseInterface self::$middlewareIn = TimingUtility::stopWatch($this->isKernel ? 'requestHandler' : 'middleware.in', $this->info); if ($this->isKernel) { - TimingUtility::end('middleware.in.total'); + $request->getAttribute('middleware.in.total')?->stop(); } $response = $this->requestHandler->handle($request); diff --git a/Classes/Middleware/XClassMiddlewareDispatcher.php b/Classes/Middleware/XClassMiddlewareDispatcher.php index 09cd48e..2bc481f 100644 --- a/Classes/Middleware/XClassMiddlewareDispatcher.php +++ b/Classes/Middleware/XClassMiddlewareDispatcher.php @@ -34,7 +34,7 @@ public function handle(ServerRequestInterface $request): ResponseInterface $stop = TimingUtility::stopWatch('bootstrap'); $stop->startTime = $_SERVER["REQUEST_TIME_FLOAT"]; $stop->stop(); - TimingUtility::start('middleware.in.total'); + $request = $request->withAttribute('middleware.in.total', TimingUtility::stopWatch('middleware.in.total')); if ($this->tip instanceof WrapMiddleware) { $this->tip->isFirst(); }