From 867690134137b38f2a15273d9899c0baeb9aed7b Mon Sep 17 00:00:00 2001 From: Kevin Pfeifer Date: Tue, 20 Jan 2026 18:00:04 +0100 Subject: [PATCH 1/3] fix transactions not being sent after response has been sent to client in a fastcgi environment --- src/Log/Engines/SentryLog.php | 6 +----- src/Middleware/CakeSentryPerformanceMiddleware.php | 2 +- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/src/Log/Engines/SentryLog.php b/src/Log/Engines/SentryLog.php index 27618a1..c1630e2 100644 --- a/src/Log/Engines/SentryLog.php +++ b/src/Log/Engines/SentryLog.php @@ -22,11 +22,7 @@ public function __construct(array $config = []) parent::__construct($config); // Send the logs to sentry after the client has received the response - if ( - PHP_SAPI !== 'cli' && - function_exists('fastcgi_finish_request') && - method_exists(Server::class, 'terminate') - ) { + if (PHP_SAPI !== 'cli' && function_exists('fastcgi_finish_request')) { $this->logsWillBeFlushed = true; EventManager::instance()->on('Server.terminate', function (): void { Logs::getInstance()->flush(); diff --git a/src/Middleware/CakeSentryPerformanceMiddleware.php b/src/Middleware/CakeSentryPerformanceMiddleware.php index b2eb6ce..9baf670 100644 --- a/src/Middleware/CakeSentryPerformanceMiddleware.php +++ b/src/Middleware/CakeSentryPerformanceMiddleware.php @@ -101,7 +101,7 @@ public function process(ServerRequestInterface $request, RequestHandlerInterface $transaction->setHttpStatus($response->getStatusCode()); - if (function_exists('fastcgi_finish_request') && method_exists(Server::class, 'terminate')) { + if (function_exists('fastcgi_finish_request')) { // Send the transaction to sentry after the client has received the response EventManager::instance()->on('Server.terminate', function () use ($transaction): void { $transaction->finish(); From fa6d27a6c88fc96feed0968db1e0f630be960bc2 Mon Sep 17 00:00:00 2001 From: Kevin Pfeifer Date: Tue, 20 Jan 2026 18:01:53 +0100 Subject: [PATCH 2/3] fix CI --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3f86a57..c17e418 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -22,7 +22,7 @@ jobs: php-version: [ '8.2', '8.3', '8.4', '8.5' ] dependencies: ['highest'] include: - - php-version: '8.1' + - php-version: '8.2' dependencies: 'lowest' steps: @@ -51,7 +51,7 @@ jobs: fi - name: Code Coverage Report - if: success() && matrix.php-version == '8.1' + if: success() && matrix.php-version == '8.2' uses: codecov/codecov-action@v5 cs-stan: From 5d7136a98ff3443197cd6efc0f7c3e098ab4240b Mon Sep 17 00:00:00 2001 From: Kevin Pfeifer Date: Tue, 20 Jan 2026 18:03:19 +0100 Subject: [PATCH 3/3] fix cs --- src/Log/Engines/SentryLog.php | 1 - src/Middleware/CakeSentryPerformanceMiddleware.php | 1 - 2 files changed, 2 deletions(-) diff --git a/src/Log/Engines/SentryLog.php b/src/Log/Engines/SentryLog.php index c1630e2..6d1ee34 100644 --- a/src/Log/Engines/SentryLog.php +++ b/src/Log/Engines/SentryLog.php @@ -4,7 +4,6 @@ namespace CakeSentry\Log\Engines; use Cake\Event\EventManager; -use Cake\Http\Server; use Cake\Log\Engine\BaseLog; use Psr\Log\LogLevel; use Sentry\Logs\Logs; diff --git a/src/Middleware/CakeSentryPerformanceMiddleware.php b/src/Middleware/CakeSentryPerformanceMiddleware.php index 9baf670..cce0493 100644 --- a/src/Middleware/CakeSentryPerformanceMiddleware.php +++ b/src/Middleware/CakeSentryPerformanceMiddleware.php @@ -16,7 +16,6 @@ use Cake\Database\Driver; use Cake\Datasource\ConnectionManager; use Cake\Event\EventManager; -use Cake\Http\Server; use CakeSentry\Database\Log\CakeSentryLog; use CakeSentry\Event\CacheEventListener; use CakeSentry\Event\HttpEventListener;