From 4a1e7b8d5ad9098bff49295384fff5e9d9b97133 Mon Sep 17 00:00:00 2001 From: Alejandro Celaya Date: Sun, 19 Dec 2021 10:23:55 +0100 Subject: [PATCH 1/4] Changed condition to pipe RequestIdMiddleware, so that it applies to non-rest requests too --- CHANGELOG.md | 17 +++++++++++++++++ config/autoload/middleware-pipeline.global.php | 2 +- config/autoload/swoole.global.php | 2 +- 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ee4a64c6..bf07ce02 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,23 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com), and this project adheres to [Semantic Versioning](https://semver.org). +## [Unreleased] +### Added +* *Nothing* + +### Changed +* *Nothing* + +### Deprecated +* *Nothing* + +### Removed +* *Nothing* + +### Fixed +* [#1286](https://github.com/shlinkio/shlink/issues/1286) Fixed `x-request-id` header not being generated during non-rest requests. + + ## [2.10.0] - 2021-12-12 ### Added * [#1163](https://github.com/shlinkio/shlink/issues/1163) Allowed setting not-found redirects for default domain in the same way it's done for any other domain. diff --git a/config/autoload/middleware-pipeline.global.php b/config/autoload/middleware-pipeline.global.php index becd3ad3..c628c4fd 100644 --- a/config/autoload/middleware-pipeline.global.php +++ b/config/autoload/middleware-pipeline.global.php @@ -17,6 +17,7 @@ return [ 'error-handler' => [ 'middleware' => [ ContentLengthMiddleware::class, + RequestIdMiddleware::class, ErrorHandler::class, Rest\Middleware\CrossDomainMiddleware::class, ], @@ -24,7 +25,6 @@ return [ 'error-handler-rest' => [ 'path' => '/rest', 'middleware' => [ - RequestIdMiddleware::class, ProblemDetails\ProblemDetailsMiddleware::class, ], ], diff --git a/config/autoload/swoole.global.php b/config/autoload/swoole.global.php index ad4e3792..f7159ed7 100644 --- a/config/autoload/swoole.global.php +++ b/config/autoload/swoole.global.php @@ -22,7 +22,7 @@ return (static function () { 'options' => [ 'worker_num' => (int) env('WEB_WORKER_NUM', 16), - 'task_worker_num' => $taskWorkers < MIN_TASK_WORKERS ? MIN_TASK_WORKERS : $taskWorkers, + 'task_worker_num' => max($taskWorkers, MIN_TASK_WORKERS), ], ], ], From 6eac079440a312582ab9dab0a5bf4c6f43079026 Mon Sep 17 00:00:00 2001 From: Alejandro Celaya Date: Tue, 21 Dec 2021 14:10:06 +0100 Subject: [PATCH 2/4] Ensured EM is closed and not cleared after running an async task --- .../src/EventDispatcher/CloseDbConnectionEventListener.php | 2 +- .../EventDispatcher/CloseDbConnectionEventListenerTest.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/module/Core/src/EventDispatcher/CloseDbConnectionEventListener.php b/module/Core/src/EventDispatcher/CloseDbConnectionEventListener.php index 079c6195..985b13c2 100644 --- a/module/Core/src/EventDispatcher/CloseDbConnectionEventListener.php +++ b/module/Core/src/EventDispatcher/CloseDbConnectionEventListener.php @@ -24,7 +24,7 @@ class CloseDbConnectionEventListener ($this->wrapped)($event); } finally { $this->em->getConnection()->close(); - $this->em->clear(); + $this->em->close(); } } } diff --git a/module/Core/test/EventDispatcher/CloseDbConnectionEventListenerTest.php b/module/Core/test/EventDispatcher/CloseDbConnectionEventListenerTest.php index 3d830cf3..d0c7c374 100644 --- a/module/Core/test/EventDispatcher/CloseDbConnectionEventListenerTest.php +++ b/module/Core/test/EventDispatcher/CloseDbConnectionEventListenerTest.php @@ -35,7 +35,7 @@ class CloseDbConnectionEventListenerTest extends TestCase $close = $conn->close()->will(function (): void { }); $getConn = $this->em->getConnection()->willReturn($conn->reveal()); - $clear = $this->em->clear()->will(function (): void { + $close = $this->em->close()->will(function (): void { }); $open = $this->em->open()->will(function (): void { }); @@ -51,7 +51,7 @@ class CloseDbConnectionEventListenerTest extends TestCase self::assertTrue($wrappedWasCalled); $close->shouldHaveBeenCalledOnce(); $getConn->shouldHaveBeenCalledOnce(); - $clear->shouldHaveBeenCalledOnce(); + $close->shouldHaveBeenCalledOnce(); $open->shouldHaveBeenCalledOnce(); } From 99a905cdee0adf72af3ae8d999bba0191ed52661 Mon Sep 17 00:00:00 2001 From: Alejandro Celaya Date: Tue, 21 Dec 2021 14:22:11 +0100 Subject: [PATCH 3/4] Updated to latest shlink-common with support to close EM on middleware --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 9652af32..b8ff3349 100644 --- a/composer.json +++ b/composer.json @@ -48,7 +48,7 @@ "predis/predis": "^1.1", "pugx/shortid-php": "^1.0", "ramsey/uuid": "^4.2", - "shlinkio/shlink-common": "^4.2", + "shlinkio/shlink-common": "^4.2.1", "shlinkio/shlink-config": "^1.4", "shlinkio/shlink-event-dispatcher": "^2.3", "shlinkio/shlink-importer": "^2.5", From 0f37f1cb23ce2fd3f62cbad3972c22e3ed586e16 Mon Sep 17 00:00:00 2001 From: Alejandro Celaya Date: Tue, 21 Dec 2021 14:25:21 +0100 Subject: [PATCH 4/4] Updated changelog --- CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bf07ce02..311479ed 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,7 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com), and this project adheres to [Semantic Versioning](https://semver.org). -## [Unreleased] +## [2.10.1] - 2021-12-21 ### Added * *Nothing* @@ -18,6 +18,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com), and this * *Nothing* ### Fixed +* [#1285](https://github.com/shlinkio/shlink/issues/1285) Fixed error caused by database connections expiring after some hours of inactivity. * [#1286](https://github.com/shlinkio/shlink/issues/1286) Fixed `x-request-id` header not being generated during non-rest requests.