From b17c576a307ed3884be27a8b95a7029e3db33e1d Mon Sep 17 00:00:00 2001 From: Alejandro Celaya Date: Thu, 15 Jun 2023 18:53:42 +0200 Subject: [PATCH 1/2] Fix incorrect timeout in init commands --- CHANGELOG.md | 17 +++++++++++++++++ composer.json | 2 +- module/CLI/src/Util/ProcessRunner.php | 4 ++-- module/Core/src/Model/DeviceType.php | 2 +- module/Rest/src/Action/Tag/ListTagsAction.php | 2 +- 5 files changed, 22 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 44125533..6539166a 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 +* [#1819](https://github.com/shlinkio/shlink/issues/1819) Fix incorrect timeout when running DB commands during Shlink start-up. + + ## [3.6.3] - 2023-06-14 ### Added * *Nothing* diff --git a/composer.json b/composer.json index 98ce47eb..8f76670b 100644 --- a/composer.json +++ b/composer.json @@ -49,7 +49,7 @@ "shlinkio/shlink-config": "^2.4", "shlinkio/shlink-event-dispatcher": "^3.0", "shlinkio/shlink-importer": "^5.1", - "shlinkio/shlink-installer": "^8.4.1", + "shlinkio/shlink-installer": "^8.4.2", "shlinkio/shlink-ip-geolocation": "^3.2", "shlinkio/shlink-json": "^1.0", "spiral/roadrunner": "^2023.1", diff --git a/module/CLI/src/Util/ProcessRunner.php b/module/CLI/src/Util/ProcessRunner.php index 1a5471e5..5a568dbe 100644 --- a/module/CLI/src/Util/ProcessRunner.php +++ b/module/CLI/src/Util/ProcessRunner.php @@ -23,8 +23,8 @@ class ProcessRunner implements ProcessRunnerInterface public function __construct(private ProcessHelper $helper, ?callable $createProcess = null) { $this->createProcess = $createProcess !== null - ? Closure::fromCallable($createProcess) - : static fn (array $cmd) => new Process($cmd, null, null, null, LockedCommandConfig::DEFAULT_TTL); + ? $createProcess(...) + : static fn (array $cmd) => new Process($cmd, timeout: LockedCommandConfig::DEFAULT_TTL); } public function run(OutputInterface $output, array $cmd): void diff --git a/module/Core/src/Model/DeviceType.php b/module/Core/src/Model/DeviceType.php index df4a1838..e394716a 100644 --- a/module/Core/src/Model/DeviceType.php +++ b/module/Core/src/Model/DeviceType.php @@ -12,7 +12,7 @@ enum DeviceType: string public static function matchFromUserAgent(string $userAgent): ?self { - $detect = new MobileDetect(null, $userAgent); // @phpstan-ignore-line + $detect = new MobileDetect(userAgent: $userAgent); // @phpstan-ignore-line return match (true) { // $detect->is('iOS') && $detect->isTablet() => self::IOS, // TODO To detect iPad only diff --git a/module/Rest/src/Action/Tag/ListTagsAction.php b/module/Rest/src/Action/Tag/ListTagsAction.php index d52436d2..34f44475 100644 --- a/module/Rest/src/Action/Tag/ListTagsAction.php +++ b/module/Rest/src/Action/Tag/ListTagsAction.php @@ -40,7 +40,7 @@ class ListTagsAction extends AbstractRestAction // This part is deprecated. To get tags with stats, the /tags/stats endpoint should be used instead $tagsInfo = $this->tagService->tagsInfo($params, $apiKey); - $rawTags = $this->serializePaginator($tagsInfo, null, 'stats'); + $rawTags = $this->serializePaginator($tagsInfo, dataProp: 'stats'); $rawTags['data'] = map($tagsInfo, static fn (TagInfo $info) => $info->tag); return new JsonResponse(['tags' => $rawTags]); From a3b2f943390f09d752c305516c12e21436de9bda Mon Sep 17 00:00:00 2001 From: Alejandro Celaya Date: Tue, 12 Sep 2023 08:21:34 +0200 Subject: [PATCH 2/2] Make sure local config is not loaded in tests --- composer.json | 2 +- config/config.php | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/composer.json b/composer.json index 8f76670b..ab187f55 100644 --- a/composer.json +++ b/composer.json @@ -18,7 +18,7 @@ "ext-json": "*", "ext-pdo": "*", "akrabat/ip-address-middleware": "^2.1", - "cakephp/chronos": "^2.3", + "cakephp/chronos": "~2.3.3", "doctrine/migrations": "^3.5", "doctrine/orm": "^2.14", "endroid/qr-code": "^4.7", diff --git a/config/config.php b/config/config.php index e0ec6c23..9df29138 100644 --- a/config/config.php +++ b/config/config.php @@ -42,10 +42,9 @@ return (new ConfigAggregator\ConfigAggregator([ Core\ConfigProvider::class, CLI\ConfigProvider::class, Rest\ConfigProvider::class, - new ConfigAggregator\PhpFileProvider('config/autoload/{{,*.}global,{,*.}local}.php'), - $isTestEnv - ? new ConfigAggregator\PhpFileProvider('config/test/*.global.php') - : new ConfigAggregator\ArrayProvider([]), + new ConfigAggregator\PhpFileProvider('config/autoload/{,*.}global.php'), + // Local config should not be loaded during tests, whereas test config should be loaded ONLY during tests + new ConfigAggregator\PhpFileProvider($isTestEnv ? 'config/test/*.global.php' : 'config/autoload/{,*.}local.php'), // Routes have to be loaded last new ConfigAggregator\PhpFileProvider('config/autoload/routes.config.php'), ], 'data/cache/app_config.php', [