From 7310ecd886b708435b9f37109d025f0231aec526 Mon Sep 17 00:00:00 2001 From: Alejandro Celaya Date: Sun, 25 Aug 2024 12:50:24 +0200 Subject: [PATCH 1/5] Allow specifying the redis database index to be used --- CHANGELOG.md | 17 +++++++++++++++++ composer.json | 2 +- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c953b99e..5e5a57ae 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 +* [#2183](https://github.com/shlinkio/shlink/issues/2183) Redis database index to be used can now be specified in the connection URI path, and Shlink will honor it. + +### Changed +* *Nothing* + +### Deprecated +* *Nothing* + +### Removed +* *Nothing* + +### Fixed +* *Nothing* + + ## [4.2.0] - 2024-08-11 ### Added * [#2120](https://github.com/shlinkio/shlink/issues/2120) Add new IP address condition for the dynamic rules redirections system. diff --git a/composer.json b/composer.json index 08c94557..eadb894f 100644 --- a/composer.json +++ b/composer.json @@ -44,7 +44,7 @@ "pagerfanta/core": "^3.8", "ramsey/uuid": "^4.7", "shlinkio/doctrine-specification": "^2.1.1", - "shlinkio/shlink-common": "^6.2", + "shlinkio/shlink-common": "dev-main#f97703b as 6.3", "shlinkio/shlink-config": "^3.0", "shlinkio/shlink-event-dispatcher": "^4.1", "shlinkio/shlink-importer": "^5.3.2", From 187c17319a5f564addc5b6b5bd8d5b8b5fc2ce1d Mon Sep 17 00:00:00 2001 From: Alejandro Celaya Date: Mon, 26 Aug 2024 09:44:13 +0200 Subject: [PATCH 2/5] Take all Postgres platform classes into consideration --- composer.json | 4 ++-- .../Core/src/Visit/Listener/OrphanVisitsCountTracker.php | 7 ++++--- .../Core/src/Visit/Listener/ShortUrlVisitsCountTracker.php | 7 ++++--- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/composer.json b/composer.json index eadb894f..d6fb9d71 100644 --- a/composer.json +++ b/composer.json @@ -20,9 +20,9 @@ "ext-pdo": "*", "akrabat/ip-address-middleware": "^2.1", "cakephp/chronos": "^3.0.2", - "doctrine/dbal": "^4.0", + "doctrine/dbal": "^4.1", "doctrine/migrations": "^3.6", - "doctrine/orm": "^3.0", + "doctrine/orm": "^3.2", "endroid/qr-code": "^5.0", "friendsofphp/proxy-manager-lts": "^1.0", "geoip2/geoip2": "^3.0", diff --git a/module/Core/src/Visit/Listener/OrphanVisitsCountTracker.php b/module/Core/src/Visit/Listener/OrphanVisitsCountTracker.php index 157d587e..a673f19e 100644 --- a/module/Core/src/Visit/Listener/OrphanVisitsCountTracker.php +++ b/module/Core/src/Visit/Listener/OrphanVisitsCountTracker.php @@ -58,9 +58,10 @@ final class OrphanVisitsCountTracker $conn = $em->getConnection(); $platformClass = $conn->getDatabasePlatform(); - match ($platformClass::class) { - PostgreSQLPlatform::class => $this->incrementForPostgres($conn, $isBot), - SQLitePlatform::class, SQLServerPlatform::class => $this->incrementForOthers($conn, $isBot), + match (true) { + $platformClass instanceof PostgreSQLPlatform => $this->incrementForPostgres($conn, $isBot), + $platformClass instanceof SQLitePlatform || $platformClass instanceof SQLServerPlatform + => $this->incrementForOthers($conn, $isBot), default => $this->incrementForMySQL($conn, $isBot), }; } diff --git a/module/Core/src/Visit/Listener/ShortUrlVisitsCountTracker.php b/module/Core/src/Visit/Listener/ShortUrlVisitsCountTracker.php index f62ddb3d..0ab8d393 100644 --- a/module/Core/src/Visit/Listener/ShortUrlVisitsCountTracker.php +++ b/module/Core/src/Visit/Listener/ShortUrlVisitsCountTracker.php @@ -64,9 +64,10 @@ final class ShortUrlVisitsCountTracker $conn = $em->getConnection(); $platformClass = $conn->getDatabasePlatform(); - match ($platformClass::class) { - PostgreSQLPlatform::class => $this->incrementForPostgres($conn, $shortUrlId, $isBot), - SQLitePlatform::class, SQLServerPlatform::class => $this->incrementForOthers($conn, $shortUrlId, $isBot), + match (true) { + $platformClass instanceof PostgreSQLPlatform => $this->incrementForPostgres($conn, $shortUrlId, $isBot), + $platformClass instanceof SQLitePlatform || $platformClass instanceof SQLServerPlatform + => $this->incrementForOthers($conn, $shortUrlId, $isBot), default => $this->incrementForMySQL($conn, $shortUrlId, $isBot), }; } From 04133991027e48f589bbaf8c5939dcdf3429613c Mon Sep 17 00:00:00 2001 From: Alejandro Celaya Date: Fri, 4 Oct 2024 12:33:27 +0200 Subject: [PATCH 3/5] Make sure MEMORY_LIMIT env var is read after config options have been promoted to env vars --- config/container.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/config/container.php b/config/container.php index bfab7763..7ae58b75 100644 --- a/config/container.php +++ b/config/container.php @@ -12,8 +12,6 @@ chdir(dirname(__DIR__)); require 'vendor/autoload.php'; -// Set a default memory limit, but allow custom values -ini_set('memory_limit', EnvVars::MEMORY_LIMIT->loadFromEnv('512M')); // This is one of the first files loaded. Configure the timezone here date_default_timezone_set(EnvVars::TIMEZONE->loadFromEnv(date_default_timezone_get())); @@ -25,6 +23,10 @@ if (! class_exists(LOCAL_LOCK_FACTORY)) { return (static function (): ServiceManager { $config = require __DIR__ . '/config.php'; + + // Set a default memory limit right after loading config, to ensure installer config has been promoted as env vars + ini_set('memory_limit', EnvVars::MEMORY_LIMIT->loadFromEnv('512M')); + $container = new ServiceManager($config['dependencies']); $container->setService('config', $config); From 447cccacdfda18ea47e8e8e0c4503260a4bb4daa Mon Sep 17 00:00:00 2001 From: Alejandro Celaya Date: Fri, 4 Oct 2024 12:37:51 +0200 Subject: [PATCH 4/5] Update changelog --- CHANGELOG.md | 4 ++-- config/container.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5e5a57ae..0696a389 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] +## [4.2.1] - 2024-10-04 ### Added * [#2183](https://github.com/shlinkio/shlink/issues/2183) Redis database index to be used can now be specified in the connection URI path, and Shlink will honor it. @@ -18,7 +18,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com), and this * *Nothing* ### Fixed -* *Nothing* +* [#2201](https://github.com/shlinkio/shlink/issues/2201) Fix `MEMORY_LIMIT` option being ignored when provided via installer options. ## [4.2.0] - 2024-08-11 diff --git a/config/container.php b/config/container.php index 7ae58b75..6e5172a4 100644 --- a/config/container.php +++ b/config/container.php @@ -24,7 +24,7 @@ if (! class_exists(LOCAL_LOCK_FACTORY)) { return (static function (): ServiceManager { $config = require __DIR__ . '/config.php'; - // Set a default memory limit right after loading config, to ensure installer config has been promoted as env vars + // Set memory limit right after loading config, to ensure installer config has been promoted as env vars ini_set('memory_limit', EnvVars::MEMORY_LIMIT->loadFromEnv('512M')); $container = new ServiceManager($config['dependencies']); From 00169a572949f4f71add7d9aeab03d61e710dc78 Mon Sep 17 00:00:00 2001 From: Alejandro Celaya Date: Fri, 4 Oct 2024 12:48:19 +0200 Subject: [PATCH 5/5] Require shlink-common 6.3 --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index d6fb9d71..77fc84a8 100644 --- a/composer.json +++ b/composer.json @@ -44,7 +44,7 @@ "pagerfanta/core": "^3.8", "ramsey/uuid": "^4.7", "shlinkio/doctrine-specification": "^2.1.1", - "shlinkio/shlink-common": "dev-main#f97703b as 6.3", + "shlinkio/shlink-common": "^6.3", "shlinkio/shlink-config": "^3.0", "shlinkio/shlink-event-dispatcher": "^4.1", "shlinkio/shlink-importer": "^5.3.2",