Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release 3.7.1 #1953

Merged
merged 13 commits into from
Dec 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,24 @@ 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).

## [3.7.1] - 2023-12-17
### Added
* *Nothing*

### Changed
* Remove dependency on functional-php library

### Deprecated
* *Nothing*

### Removed
* *Nothing*

### Fixed
* [#1947](https://github.com/shlinkio/shlink/issues/1947) Fix error when importing short URLs while using Postgres.
* [#1939](https://github.com/shlinkio/shlink/issues/1939) Fine-tune RoadRunner logs to avoid too many useless info.


## [3.7.0] - 2023-11-25
### Added
* [#1798](https://github.com/shlinkio/shlink/issues/1798) Experimental support to send visits to an external Matomo instance.
Expand Down
17 changes: 10 additions & 7 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,17 @@
"doctrine/orm": "^2.16",
"endroid/qr-code": "^4.8",
"friendsofphp/proxy-manager-lts": "^1.0",
"geoip2/geoip2": "^2.13",
"geoip2/geoip2": "^3.0",
"guzzlehttp/guzzle": "^7.5",
"happyr/doctrine-specification": "^2.0",
"jaybizzle/crawler-detect": "^1.2.116",
"laminas/laminas-config": "^3.8",
"laminas/laminas-config-aggregator": "^1.13",
"laminas/laminas-diactoros": "^2.25",
"laminas/laminas-diactoros": "^3.3",
"laminas/laminas-inputfilter": "^2.27",
"laminas/laminas-servicemanager": "^3.21",
"laminas/laminas-stdlib": "^3.17",
"league/uri": "^6.8",
"lstrojny/functional-php": "^1.17",
"matomo/matomo-php-tracker": "^3.2",
"mezzio/mezzio": "^3.17",
"mezzio/mezzio-fastroute": "^3.10",
Expand All @@ -46,12 +45,12 @@
"php-middleware/request-id": "^4.1",
"pugx/shortid-php": "^1.1",
"ramsey/uuid": "^4.7",
"shlinkio/shlink-common": "^5.7",
"shlinkio/shlink-common": "^5.7.1",
"shlinkio/shlink-config": "^2.5",
"shlinkio/shlink-event-dispatcher": "^3.1",
"shlinkio/shlink-importer": "^5.2",
"shlinkio/shlink-installer": "^8.6",
"shlinkio/shlink-ip-geolocation": "^3.3",
"shlinkio/shlink-importer": "^5.2.1",
"shlinkio/shlink-installer": "^8.6.1",
"shlinkio/shlink-ip-geolocation": "^3.4",
"shlinkio/shlink-json": "^1.1",
"spiral/roadrunner": "^2023.2",
"spiral/roadrunner-cli": "^2.5",
Expand Down Expand Up @@ -80,6 +79,9 @@
"symfony/var-dumper": "^6.3",
"veewee/composer-run-parallel": "^1.3"
},
"conflict": {
"symfony/var-exporter": ">=6.3.9,<=6.4.0"
},
"autoload": {
"psr-4": {
"Shlinkio\\Shlink\\CLI\\": "module/CLI/src",
Expand All @@ -88,6 +90,7 @@
},
"files": [
"config/constants.php",
"module/Core/functions/array-utils.php",
"module/Core/functions/functions.php"
]
},
Expand Down
4 changes: 2 additions & 2 deletions config/autoload/entity-manager.global.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
use Happyr\DoctrineSpecification\Repository\EntitySpecificationRepository;
use Shlinkio\Shlink\Core\Config\EnvVars;

use function Functional\contains;
use function Shlinkio\Shlink\Core\ArrayUtils\contains;

return (static function (): array {
$driver = EnvVars::DB_DRIVER->loadFromEnv();
$isMysqlCompatible = contains(['maria', 'mysql'], $driver);
$isMysqlCompatible = contains($driver, ['maria', 'mysql']);

$resolveDriver = static fn () => match ($driver) {
'postgres' => 'pdo_pgsql',
Expand Down
4 changes: 3 additions & 1 deletion config/roadrunner/.rr.dev.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version: '3.0'
version: '3'

rpc:
listen: tcp://127.0.0.1:6001
Expand Down Expand Up @@ -38,3 +38,5 @@ logs:
level: debug
metrics:
level: debug
jobs:
level: debug
6 changes: 4 additions & 2 deletions config/roadrunner/.rr.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version: '3.0'
version: '3'

rpc:
listen: tcp://127.0.0.1:6001
Expand Down Expand Up @@ -33,4 +33,6 @@ logs:
http:
mode: 'off' # Disable logging as Shlink handles it internally
server:
level: debug # Everything written to worker stderr is logged
level: info
jobs:
level: debug
4 changes: 2 additions & 2 deletions config/test/test_config.global.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@
use Symfony\Contracts\EventDispatcher\EventDispatcherInterface;

use function file_exists;
use function Functional\contains;
use function Laminas\Stratigility\middleware;
use function Shlinkio\Shlink\Config\env;
use function Shlinkio\Shlink\Core\ArrayUtils\contains;
use function sprintf;
use function sys_get_temp_dir;

Expand All @@ -41,7 +41,7 @@
$isCliTest = env('TEST_ENV') === 'cli';
$isE2eTest = $isApiTest || $isCliTest;
$coverageType = env('GENERATE_COVERAGE');
$generateCoverage = contains(['yes', 'pretty'], $coverageType);
$generateCoverage = contains($coverageType, ['yes', 'pretty']);

$coverage = null;
if ($isE2eTest && $generateCoverage) {
Expand Down
4 changes: 2 additions & 2 deletions data/migrations/Version20200105165647.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
use Doctrine\DBAL\Types\Types;
use Doctrine\Migrations\AbstractMigration;

use function Functional\some;
use function Shlinkio\Shlink\Core\ArrayUtils\some;

final class Version20200105165647 extends AbstractMigration
{
Expand All @@ -25,7 +25,7 @@ public function preUp(Schema $schema): void
$visitLocations = $schema->getTable('visit_locations');
$this->skipIf(some(
self::COLUMNS,
fn (string $v, string $newColName) => $visitLocations->hasColumn($newColName),
fn (string $v, string|int $newColName) => $visitLocations->hasColumn((string) $newColName),
), 'New columns already exist');

foreach (self::COLUMNS as $columnName) {
Expand Down
19 changes: 13 additions & 6 deletions data/migrations/Version20200106215144.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,10 @@
use Doctrine\DBAL\Exception;
use Doctrine\DBAL\Platforms\MySQLPlatform;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\DBAL\Schema\Table;
use Doctrine\DBAL\Types\Types;
use Doctrine\Migrations\AbstractMigration;

use function Functional\none;

final class Version20200106215144 extends AbstractMigration
{
private const COLUMNS = ['latitude', 'longitude'];
Expand All @@ -22,16 +21,24 @@ final class Version20200106215144 extends AbstractMigration
public function up(Schema $schema): void
{
$visitLocations = $schema->getTable('visit_locations');
$this->skipIf(none(
self::COLUMNS,
fn (string $oldColName) => $visitLocations->hasColumn($oldColName),
), 'Old columns do not exist');
$this->skipIf($this->oldColumnsDoNotExist($visitLocations), 'Old columns do not exist');

foreach (self::COLUMNS as $colName) {
$visitLocations->dropColumn($colName);
}
}

public function oldColumnsDoNotExist(Table $visitLocations): bool
{
foreach (self::COLUMNS as $oldColName) {
if ($visitLocations->hasColumn($oldColName)) {
return false;
}
}

return true;
}

/**
* @throws Exception
*/
Expand Down
13 changes: 5 additions & 8 deletions data/migrations/Version20200110182849.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;

use function Functional\each;
use function Functional\partial_left;

final class Version20200110182849 extends AbstractMigration
{
private const DEFAULT_EMPTY_VALUE = '';
Expand All @@ -31,11 +28,11 @@ final class Version20200110182849 extends AbstractMigration

public function up(Schema $schema): void
{
each(
self::COLUMN_DEFAULTS_MAP,
fn (array $columns, string $tableName) =>
each($columns, partial_left([$this, 'setDefaultValueForColumnInTable'], $tableName)),
);
foreach (self::COLUMN_DEFAULTS_MAP as $tableName => $columns) {
foreach ($columns as $columnName) {
$this->setDefaultValueForColumnInTable($tableName, $columnName);
}
}
}

/**
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ services:

shlink_swagger_ui:
container_name: shlink_swagger_ui
image: swaggerapi/swagger-ui:v5.9.1
image: swaggerapi/swagger-ui:v5.10.3
ports:
- "8005:8080"
volumes:
Expand Down
6 changes: 3 additions & 3 deletions module/CLI/src/Command/Api/ListKeysCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
use Symfony\Component\Console\Output\OutputInterface;

use function array_filter;
use function Functional\map;
use function array_map;
use function implode;
use function sprintf;

Expand Down Expand Up @@ -49,7 +49,7 @@ protected function execute(InputInterface $input, OutputInterface $output): ?int
{
$enabledOnly = $input->getOption('enabled-only');

$rows = map($this->apiKeyService->listKeys($enabledOnly), function (ApiKey $apiKey) use ($enabledOnly) {
$rows = array_map(function (ApiKey $apiKey) use ($enabledOnly) {
$expiration = $apiKey->getExpirationDate();
$messagePattern = $this->determineMessagePattern($apiKey);

Expand All @@ -64,7 +64,7 @@ protected function execute(InputInterface $input, OutputInterface $output): ?int
));

return $rowData;
});
}, $this->apiKeyService->listKeys($enabledOnly));

ShlinkTable::withRowSeparators($output)->render(array_filter([
'Key',
Expand Down
10 changes: 5 additions & 5 deletions module/CLI/src/Command/Db/CreateDatabaseCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
use Symfony\Component\Process\PhpExecutableFinder;
use Throwable;

use function Functional\contains;
use function Functional\map;
use function Functional\some;
use function array_map;
use function Shlinkio\Shlink\Core\ArrayUtils\contains;
use function Shlinkio\Shlink\Core\ArrayUtils\some;

class CreateDatabaseCommand extends AbstractDatabaseCommand
{
Expand Down Expand Up @@ -70,11 +70,11 @@ private function databaseTablesExist(): bool
{
$existingTables = $this->ensureDatabaseExistsAndGetTables();
$allMetadata = $this->em->getMetadataFactory()->getAllMetadata();
$shlinkTables = map($allMetadata, static fn (ClassMetadata $metadata) => $metadata->getTableName());
$shlinkTables = array_map(static fn (ClassMetadata $metadata) => $metadata->getTableName(), $allMetadata);

// If at least one of the shlink tables exist, we will consider the database exists somehow.
// Any other inconsistency will be taken care of by the migrations.
return some($shlinkTables, static fn (string $shlinkTable) => contains($existingTables, $shlinkTable));
return some($shlinkTables, static fn (string $shlinkTable) => contains($shlinkTable, $existingTables));
}

private function ensureDatabaseExistsAndGetTables(): array
Expand Down
12 changes: 6 additions & 6 deletions module/CLI/src/Command/Domain/DomainRedirectsCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,16 @@
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Style\SymfonyStyle;

use function Functional\filter;
use function Functional\invoke;
use function array_filter;
use function array_map;
use function sprintf;
use function str_contains;

class DomainRedirectsCommand extends Command
{
public const NAME = 'domain:redirects';

public function __construct(private DomainServiceInterface $domainService)
public function __construct(private readonly DomainServiceInterface $domainService)
{
parent::__construct();
}
Expand Down Expand Up @@ -52,9 +52,9 @@ protected function interact(InputInterface $input, OutputInterface $output): voi
$askNewDomain = static fn () => $io->ask('Domain authority for which you want to set specific redirects');

/** @var string[] $availableDomains */
$availableDomains = invoke(
filter($this->domainService->listDomains(), static fn (DomainItem $item) => ! $item->isDefault),
'toString',
$availableDomains = array_map(
static fn (DomainItem $item) => $item->toString(),
array_filter($this->domainService->listDomains(), static fn (DomainItem $item) => ! $item->isDefault),
);
if (empty($availableDomains)) {
$input->setArgument('domain', $askNewDomain());
Expand Down
8 changes: 4 additions & 4 deletions module/CLI/src/Command/Domain/ListDomainsCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;

use function Functional\map;
use function array_map;

class ListDomainsCommand extends Command
{
public const NAME = 'domain:list';

public function __construct(private DomainServiceInterface $domainService)
public function __construct(private readonly DomainServiceInterface $domainService)
{
parent::__construct();
}
Expand All @@ -47,7 +47,7 @@ protected function execute(InputInterface $input, OutputInterface $output): ?int

$table->render(
$showRedirects ? [...$commonFields, '"Not found" redirects'] : $commonFields,
map($domains, function (DomainItem $domain) use ($showRedirects) {
array_map(function (DomainItem $domain) use ($showRedirects) {
$commonValues = [$domain->toString(), $domain->isDefault ? 'Yes' : 'No'];

return $showRedirects
Expand All @@ -56,7 +56,7 @@ protected function execute(InputInterface $input, OutputInterface $output): ?int
$this->notFoundRedirectsToString($domain->notFoundRedirectConfig),
]
: $commonValues;
}),
}, $domains),
);

return ExitCode::EXIT_SUCCESS;
Expand Down
9 changes: 4 additions & 5 deletions module/CLI/src/Command/ShortUrl/CreateShortUrlCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,9 @@
use Symfony\Component\Console\Style\SymfonyStyle;

use function array_map;
use function array_unique;
use function explode;
use function Functional\curry;
use function Functional\flatten;
use function Functional\unique;
use function Shlinkio\Shlink\Core\ArrayUtils\flatten;
use function sprintf;

class CreateShortUrlCommand extends Command
Expand Down Expand Up @@ -144,8 +143,8 @@ protected function execute(InputInterface $input, OutputInterface $output): ?int
return ExitCode::EXIT_FAILURE;
}

$explodeWithComma = curry(explode(...))(',');
$tags = unique(flatten(array_map($explodeWithComma, $input->getOption('tags'))));
$explodeWithComma = static fn (string $tag) => explode(',', $tag);
$tags = array_unique(flatten(array_map($explodeWithComma, $input->getOption('tags'))));
$customSlug = $input->getOption('custom-slug');
$maxVisits = $input->getOption('max-visits');
$shortCodeLength = $input->getOption('short-code-length') ?? $this->options->defaultShortCodesLength;
Expand Down
Loading
Loading