From 5c8be4b21f0e745f270662a62cc1c556c9585768 Mon Sep 17 00:00:00 2001 From: Alejandro Celaya Date: Sat, 18 Dec 2021 18:17:45 +0100 Subject: [PATCH 1/4] Updated logic to handle visits threshold env var so that it is disabled if not provided --- UPGRADE.md | 6 ++++++ bin/install | 12 ------------ bin/set-option | 14 -------------- bin/update | 12 ------------ config/autoload/delete_short_urls.global.php | 16 +++++++++------- 5 files changed, 15 insertions(+), 45 deletions(-) delete mode 100755 bin/install delete mode 100755 bin/set-option delete mode 100755 bin/update diff --git a/UPGRADE.md b/UPGRADE.md index 815dc2dd..fa6c3c7f 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -20,6 +20,10 @@ * `tag:create`: Creating orphan tags makes no sense. * Params in camelCase format are no longer supported. They all have an equivalent kebab-case replacement. (for example, from `--startDate` to `--start-date`). * The `short-url:create` command no longer accepts the `--no-validate-url` flag. Now URLs are never validated, unless `--validate-url` is passed. +* The CLI installer tool entry-points have changed. + * `bin/install`: replaced by `vendor/bin/shlink-installer install` + * `bin/update`: replaced by `vendor/bin/shlink-installer update` + * `bin/set-option`: replaced by `vendor/bin/shlink-installer set-option` ### Changes in config @@ -31,6 +35,8 @@ * `SHORT_DOMAIN_SCHEMA`: Replaced by `IS_HTTPS_ENABLED`. * `USE_HTTPS`: Replaced by `IS_HTTPS_ENABLED`. * `VALIDATE_URLS`: There's no replacement. URLs are not validated, unless explicitly requested during creation or edition. +* The next env vars behavior has changed: + * `DELETE_SHORT_URL_THRESHOLD`: Now, if this env var is not provided, the "visits threshold" won't be checked at all when deleting short URLs. Make sure you explicitly provide a value if you want to enable this feature. ### Other changes diff --git a/bin/install b/bin/install deleted file mode 100755 index d20db86d..00000000 --- a/bin/install +++ /dev/null @@ -1,12 +0,0 @@ -#!/usr/bin/env php - [ - 'check_visits_threshold' => true, - 'visits_threshold' => (int) env('DELETE_SHORT_URL_THRESHOLD', DEFAULT_DELETE_SHORT_URL_THRESHOLD), - ], + 'delete_short_urls' => [ + 'check_visits_threshold' => $threshold !== null, + 'visits_threshold' => (int) ($threshold ?? DEFAULT_DELETE_SHORT_URL_THRESHOLD), + ], -]; + ]; +})(); From 2c6b2b47a45b2841ff1ddd9f4dca1c0e79836fb1 Mon Sep 17 00:00:00 2001 From: Alejandro Celaya Date: Sat, 18 Dec 2021 18:23:27 +0100 Subject: [PATCH 2/4] Updated installer --- composer.json | 2 +- config/autoload/installer.global.php | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/composer.json b/composer.json index a2fbe583..3f8f256e 100644 --- a/composer.json +++ b/composer.json @@ -52,7 +52,7 @@ "shlinkio/shlink-config": "^1.4", "shlinkio/shlink-event-dispatcher": "^2.3", "shlinkio/shlink-importer": "^2.5", - "shlinkio/shlink-installer": "^6.3", + "shlinkio/shlink-installer": "dev-develop#64f8ab2 as 7.0", "shlinkio/shlink-ip-geolocation": "^2.2", "symfony/console": "^6.0", "symfony/filesystem": "^6.0", diff --git a/config/autoload/installer.global.php b/config/autoload/installer.global.php index 238dea42..9259b061 100644 --- a/config/autoload/installer.global.php +++ b/config/autoload/installer.global.php @@ -22,7 +22,6 @@ return [ Option\Database\DatabaseMySqlOptionsConfigOption::class, Option\UrlShortener\ShortDomainHostConfigOption::class, Option\UrlShortener\ShortDomainSchemaConfigOption::class, - Option\UrlShortener\ValidateUrlConfigOption::class, Option\Visit\VisitsWebhooksConfigOption::class, Option\Visit\OrphanVisitsWebhooksConfigOption::class, Option\Redirect\BaseUrlRedirectConfigOption::class, @@ -33,7 +32,7 @@ return [ Option\BasePathConfigOption::class, Option\Worker\TaskWorkerNumConfigOption::class, Option\Worker\WebWorkerNumConfigOption::class, - Option\RedisServersConfigOption::class, + Option\RedisConfigOption::class, Option\UrlShortener\ShortCodeLengthOption::class, Option\Mercure\EnableMercureConfigOption::class, Option\Mercure\MercurePublicUrlConfigOption::class, From 970f20275791e331e6e19d29df6b6eb3cffab66b Mon Sep 17 00:00:00 2001 From: Alejandro Celaya Date: Sat, 18 Dec 2021 18:26:27 +0100 Subject: [PATCH 3/4] Updated changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index fad83e95..441218f6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com), and this ### Changed * [#1268](https://github.com/shlinkio/shlink/issues/1268) Updated dependencies, including symfony/console 6 and mezzio/mezzio-swoole 4. +* [#1283](https://github.com/shlinkio/shlink/issues/1283) Changed behavior of `DELETE_SHORT_URL_THRESHOLD` env var, disabling the feature if a value was not provided. ### Deprecated * *Nothing* From 277d817429f503c2c3a78ec0ff6446b933262cc6 Mon Sep 17 00:00:00 2001 From: Alejandro Celaya Date: Sat, 18 Dec 2021 18:41:11 +0100 Subject: [PATCH 4/4] Removed API test which is no longer relevant --- .../test-api/Action/DeleteShortUrlTest.php | 20 ------------------- 1 file changed, 20 deletions(-) diff --git a/module/Rest/test-api/Action/DeleteShortUrlTest.php b/module/Rest/test-api/Action/DeleteShortUrlTest.php index 01b5b7bc..5cac3dbd 100644 --- a/module/Rest/test-api/Action/DeleteShortUrlTest.php +++ b/module/Rest/test-api/Action/DeleteShortUrlTest.php @@ -33,26 +33,6 @@ class DeleteShortUrlTest extends ApiTestCase self::assertEquals($domain, $payload['domain'] ?? null); } - /** @test */ - public function unprocessableEntityIsReturnedWhenTryingToDeleteUrlWithTooManyVisits(): void - { - // Generate visits first - for ($i = 0; $i < 20; $i++) { - self::assertEquals(self::STATUS_FOUND, $this->callShortUrl('abc123')->getStatusCode()); - } - $expectedDetail = 'Impossible to delete short URL with short code "abc123", since it has more than "15" ' - . 'visits.'; - - $resp = $this->callApiWithKey(self::METHOD_DELETE, '/short-urls/abc123'); - $payload = $this->getJsonResponsePayload($resp); - - self::assertEquals(self::STATUS_UNPROCESSABLE_ENTITY, $resp->getStatusCode()); - self::assertEquals(self::STATUS_UNPROCESSABLE_ENTITY, $payload['status']); - self::assertEquals('INVALID_SHORT_URL_DELETION', $payload['type']); - self::assertEquals($expectedDetail, $payload['detail']); - self::assertEquals('Cannot delete short URL', $payload['title']); - } - /** @test */ public function properShortUrlIsDeletedWhenDomainIsProvided(): void {