Skip to content

Commit 5d2c6b7

Browse files
authored
Merge pull request #234 from shlinkio/develop
Release 9.4.0
2 parents f863285 + 0fec6e8 commit 5d2c6b7

File tree

9 files changed

+209
-11
lines changed

9 files changed

+209
-11
lines changed

CHANGELOG.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,24 @@ All notable changes to this project will be documented in this file.
44

55
The format is based on [Keep a Changelog](https://keepachangelog.com), and this project adheres to [Semantic Versioning](https://semver.org).
66

7+
## [9.4.0] - 2024-12-27
8+
### Added
9+
* Add config option for `REDIRECT_EXTRA_PATH_MODE`
10+
* Add config option for `DB_USE_ENCRYPTION`
11+
12+
### Changed
13+
* *Nothing*
14+
15+
### Deprecated
16+
* Deprecate `AppendExtraPathConfigOption`.
17+
18+
### Removed
19+
* *Nothing*
20+
21+
### Fixed
22+
* *Nothing*
23+
24+
725
## [9.3.0] - 2024-11-24
826
### Added
927
* *Nothing*

composer.json

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,23 +13,23 @@
1313
],
1414
"require": {
1515
"php": "^8.2",
16-
"laminas/laminas-config-aggregator": "^1.15",
17-
"laminas/laminas-servicemanager": "^4.2 || ^3.22",
18-
"laminas/laminas-stdlib": "^3.19",
19-
"shlinkio/shlink-config": "^3.1",
20-
"symfony/console": "^7.1",
21-
"symfony/filesystem": "^7.1",
22-
"symfony/process": "^7.1",
16+
"laminas/laminas-config-aggregator": "^1.17",
17+
"laminas/laminas-servicemanager": "^4.3 || ^3.23",
18+
"laminas/laminas-stdlib": "^3.20",
19+
"shlinkio/shlink-config": "^3.4",
20+
"symfony/console": "^7.2",
21+
"symfony/filesystem": "^7.2",
22+
"symfony/process": "^7.2",
2323
"webimpress/safe-writer": "^2.2"
2424
},
2525
"require-dev": {
2626
"devster/ubench": "^2.1",
2727
"phpstan/phpstan": "^2.0",
2828
"phpstan/phpstan-phpunit": "^2.0",
29-
"phpunit/phpunit": "^11.3",
29+
"phpunit/phpunit": "^11.5",
3030
"roave/security-advisories": "dev-master",
3131
"shlinkio/php-coding-standard": "~2.4.0",
32-
"symfony/var-dumper": "^7.1"
32+
"symfony/var-dumper": "^7.2"
3333
},
3434
"autoload": {
3535
"psr-4": {

config/config.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
'Database > Password' => Config\Option\Database\DatabasePasswordConfigOption::class,
5353
'Database > Unix socket (Mysql/MariaDB)'
5454
=> Config\Option\Database\DatabaseUnixSocketConfigOption::class,
55+
'Database > Use encryption' => Config\Option\Database\DatabaseUseEncryptionConfigOption::class,
5556
],
5657
'URL SHORTENER' => [
5758
'URL shortener > Short domain' => Config\Option\UrlShortener\ShortDomainHostConfigOption::class,
@@ -60,6 +61,7 @@
6061
'URL shortener > Auto resolve titles'
6162
=> Config\Option\UrlShortener\AutoResolveTitlesConfigOption::class,
6263
'URL shortener > Append extra path' => Config\Option\UrlShortener\AppendExtraPathConfigOption::class,
64+
'URL shortener > Extra path mode' => Config\Option\UrlShortener\ExtraPathModeConfigOption::class,
6365
'URL shortener > Multi-segment slugs'
6466
=> Config\Option\UrlShortener\EnableMultiSegmentSlugsConfigOption::class,
6567
'URL shortener > Trailing slashes' => Config\Option\UrlShortener\EnableTrailingSlashConfigOption::class,
@@ -142,13 +144,15 @@
142144
Config\Option\Database\DatabaseUserConfigOption::class => InvokableFactory::class,
143145
Config\Option\Database\DatabasePasswordConfigOption::class => InvokableFactory::class,
144146
Config\Option\Database\DatabaseUnixSocketConfigOption::class => InvokableFactory::class,
147+
Config\Option\Database\DatabaseUseEncryptionConfigOption::class => InvokableFactory::class,
145148
Config\Option\Redirect\BaseUrlRedirectConfigOption::class => InvokableFactory::class,
146149
Config\Option\Redirect\InvalidShortUrlRedirectConfigOption::class => InvokableFactory::class,
147150
Config\Option\Redirect\Regular404RedirectConfigOption::class => InvokableFactory::class,
148151
Config\Option\UrlShortener\ShortDomainHostConfigOption::class => InvokableFactory::class,
149152
Config\Option\UrlShortener\ShortDomainSchemaConfigOption::class => InvokableFactory::class,
150153
Config\Option\UrlShortener\AutoResolveTitlesConfigOption::class => InvokableFactory::class,
151154
Config\Option\UrlShortener\AppendExtraPathConfigOption::class => InvokableFactory::class,
155+
Config\Option\UrlShortener\ExtraPathModeConfigOption::class => InvokableFactory::class,
152156
Config\Option\UrlShortener\EnableMultiSegmentSlugsConfigOption::class => InvokableFactory::class,
153157
Config\Option\UrlShortener\EnableTrailingSlashConfigOption::class => InvokableFactory::class,
154158
Config\Option\UrlShortener\ShortUrlModeConfigOption::class => InvokableFactory::class,
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Shlinkio\Shlink\Installer\Config\Option\Database;
6+
7+
use Symfony\Component\Console\Style\StyleInterface;
8+
9+
class DatabaseUseEncryptionConfigOption extends AbstractNonSqliteDependentConfigOption
10+
{
11+
public function getEnvVar(): string
12+
{
13+
return 'DB_USE_ENCRYPTION';
14+
}
15+
16+
public function ask(StyleInterface $io, array $currentOptions): bool
17+
{
18+
return $io->confirm(
19+
'Do you want the database connection to be encrypted? Enabling this will make database connections fail if '
20+
. 'your database server does not support or enforce encryption.',
21+
default: false,
22+
);
23+
}
24+
}

src/Config/Option/UrlShortener/AppendExtraPathConfigOption.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use Shlinkio\Shlink\Installer\Config\Option\BaseConfigOption;
88
use Symfony\Component\Console\Style\StyleInterface;
99

10+
/** @deprecated */
1011
class AppendExtraPathConfigOption extends BaseConfigOption
1112
{
1213
public function getEnvVar(): string
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Shlinkio\Shlink\Installer\Config\Option\UrlShortener;
6+
7+
use Shlinkio\Shlink\Installer\Config\Option\BaseConfigOption;
8+
use Symfony\Component\Console\Style\StyleInterface;
9+
10+
class ExtraPathModeConfigOption extends BaseConfigOption
11+
{
12+
public const MODES = [
13+
'default' => 'Match strictly',
14+
'append' => 'Append extra path',
15+
'ignore' => 'Discard extra path',
16+
];
17+
18+
public function getEnvVar(): string
19+
{
20+
return 'REDIRECT_EXTRA_PATH_MODE';
21+
}
22+
23+
public function ask(StyleInterface $io, array $currentOptions): string
24+
{
25+
return $io->choice(
26+
question: <<<QUESTION
27+
Do you want Shlink to redirect short URLs as soon as the first segment of the path matches a short code?
28+
29+
append:
30+
* {shortDomain}/{shortCode}/[...extraPath] -> {longUrl}/[...extraPath]
31+
* https://s.test/abc123 -> https://www.example.com
32+
* https://s.test/abc123/shlinkio -> https://www.example.com/shlinkio
33+
34+
ignore:
35+
* {shortDomain}/{shortCode}/[...extraPath] -> {longUrl}
36+
* https://s.test/abc123 -> https://www.example.com
37+
* https://s.test/abc123/shlinkio -> https://www.example.com
38+
39+
40+
QUESTION,
41+
choices: self::MODES,
42+
default: 'default',
43+
);
44+
}
45+
}

src/Config/Option/UrlShortener/ShortUrlModeConfigOption.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,13 @@ public function getEnvVar(): string
2525

2626
public function ask(StyleInterface $io, array $currentOptions): string
2727
{
28-
$options = self::MODES;
2928
return $io->choice(
3029
'How do you want short URLs to be matched?'
3130
. PHP_EOL
3231
. '<options=bold;fg=yellow> Warning!</> <comment>This feature is experimental. It only applies to public '
3332
. 'routes (short URLs and QR codes). REST API routes always use strict match.</comment>'
3433
. PHP_EOL,
35-
$options,
34+
self::MODES,
3635
'strict',
3736
);
3837
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace ShlinkioTest\Shlink\Installer\Config\Option\Database;
6+
7+
use PHPUnit\Framework\Attributes\Test;
8+
use PHPUnit\Framework\Attributes\TestWith;
9+
use PHPUnit\Framework\TestCase;
10+
use Shlinkio\Shlink\Installer\Config\Option\Database\DatabaseUseEncryptionConfigOption;
11+
use Symfony\Component\Console\Style\StyleInterface;
12+
13+
class DatabaseUseEncryptionConfigOptionTest extends TestCase
14+
{
15+
private DatabaseUseEncryptionConfigOption $configOption;
16+
17+
public function setUp(): void
18+
{
19+
$this->configOption = new DatabaseUseEncryptionConfigOption();
20+
}
21+
22+
#[Test]
23+
public function returnsExpectedEnvVar(): void
24+
{
25+
self::assertEquals('DB_USE_ENCRYPTION', $this->configOption->getEnvVar());
26+
}
27+
28+
#[Test]
29+
#[TestWith([true])]
30+
#[TestWith([false])]
31+
public function expectedQuestionIsAsked(bool $expectedAnswer): void
32+
{
33+
$io = $this->createMock(StyleInterface::class);
34+
$io->expects($this->once())->method('confirm')->with(
35+
'Do you want the database connection to be encrypted? Enabling this will make database connections fail if '
36+
. 'your database server does not support or enforce encryption.',
37+
false,
38+
)->willReturn($expectedAnswer);
39+
40+
$answer = $this->configOption->ask($io, []);
41+
42+
self::assertEquals($expectedAnswer, $answer);
43+
}
44+
}
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace ShlinkioTest\Shlink\Installer\Config\Option\UrlShortener;
6+
7+
use PHPUnit\Framework\Attributes\DataProvider;
8+
use PHPUnit\Framework\Attributes\Test;
9+
use PHPUnit\Framework\TestCase;
10+
use Shlinkio\Shlink\Installer\Config\Option\UrlShortener\ExtraPathModeConfigOption;
11+
use Symfony\Component\Console\Style\StyleInterface;
12+
13+
class ExtraPathModeConfigOptionTest extends TestCase
14+
{
15+
private ExtraPathModeConfigOption $configOption;
16+
17+
public function setUp(): void
18+
{
19+
$this->configOption = new ExtraPathModeConfigOption();
20+
}
21+
22+
#[Test]
23+
public function returnsExpectedEnvVar(): void
24+
{
25+
self::assertEquals('REDIRECT_EXTRA_PATH_MODE', $this->configOption->getEnvVar());
26+
}
27+
28+
#[Test, DataProvider('provideChoices')]
29+
public function expectedQuestionIsAsked(string $choice): void
30+
{
31+
$io = $this->createMock(StyleInterface::class);
32+
$io->expects($this->once())->method('choice')->with(
33+
<<<QUESTION
34+
Do you want Shlink to redirect short URLs as soon as the first segment of the path matches a short code?
35+
36+
append:
37+
* {shortDomain}/{shortCode}/[...extraPath] -> {longUrl}/[...extraPath]
38+
* https://s.test/abc123 -> https://www.example.com
39+
* https://s.test/abc123/shlinkio -> https://www.example.com/shlinkio
40+
41+
ignore:
42+
* {shortDomain}/{shortCode}/[...extraPath] -> {longUrl}
43+
* https://s.test/abc123 -> https://www.example.com
44+
* https://s.test/abc123/shlinkio -> https://www.example.com
45+
46+
47+
QUESTION,
48+
ExtraPathModeConfigOption::MODES,
49+
'default',
50+
)->willReturn($choice);
51+
52+
$answer = $this->configOption->ask($io, []);
53+
54+
self::assertEquals($choice, $answer);
55+
}
56+
57+
public static function provideChoices(): iterable
58+
{
59+
foreach (ExtraPathModeConfigOption::MODES as $mode => $_) {
60+
yield $mode => [$mode];
61+
}
62+
}
63+
}

0 commit comments

Comments
 (0)