Merge pull request #599 from acelaya-forks/feature/update-shlink-packages

Feature/update shlink packages
This commit is contained in:
Alejandro Celaya 2020-01-06 23:19:52 +01:00 committed by GitHub
commit 96eb6a80e1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
23 changed files with 233 additions and 109 deletions

View File

@ -10,6 +10,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com), and this
* [#429](https://github.com/shlinkio/shlink/issues/429) Added support for PHP 7.4 * [#429](https://github.com/shlinkio/shlink/issues/429) Added support for PHP 7.4
* [#529](https://github.com/shlinkio/shlink/issues/529) Created an UPGRADING.md file explaining how to upgrade from v1.x to v2.x * [#529](https://github.com/shlinkio/shlink/issues/529) Created an UPGRADING.md file explaining how to upgrade from v1.x to v2.x
* [#594](https://github.com/shlinkio/shlink/issues/594) Updated external shlink packages, including installer v4.0, which adds the option to ask for the redis cluster config.
#### Changed #### Changed

View File

@ -8,5 +8,5 @@ use function chdir;
use function dirname; use function dirname;
chdir(dirname(__DIR__)); chdir(dirname(__DIR__));
$run = require __DIR__ . '/../vendor/shlinkio/shlink-installer/bin/run.php'; [$install] = require __DIR__ . '/../vendor/shlinkio/shlink-installer/bin/run.php';
$run(false); $install();

View File

@ -8,5 +8,5 @@ use function chdir;
use function dirname; use function dirname;
chdir(dirname(__DIR__)); chdir(dirname(__DIR__));
$run = require __DIR__ . '/../vendor/shlinkio/shlink-installer/bin/run.php'; [, $update] = require __DIR__ . '/../vendor/shlinkio/shlink-installer/bin/run.php';
$run(true); $update();

View File

@ -28,7 +28,7 @@
"guzzlehttp/guzzle": "^6.5.1", "guzzlehttp/guzzle": "^6.5.1",
"laminas/laminas-config": "^3.3", "laminas/laminas-config": "^3.3",
"laminas/laminas-config-aggregator": "^1.1", "laminas/laminas-config-aggregator": "^1.1",
"laminas/laminas-dependency-plugin": "^0.2", "laminas/laminas-dependency-plugin": "^1.0",
"laminas/laminas-diactoros": "^2.1.3", "laminas/laminas-diactoros": "^2.1.3",
"laminas/laminas-inputfilter": "^2.10", "laminas/laminas-inputfilter": "^2.10",
"laminas/laminas-paginator": "^2.8", "laminas/laminas-paginator": "^2.8",
@ -47,10 +47,10 @@
"phly/phly-event-dispatcher": "^1.0", "phly/phly-event-dispatcher": "^1.0",
"predis/predis": "^1.1", "predis/predis": "^1.1",
"pugx/shortid-php": "^0.5", "pugx/shortid-php": "^0.5",
"shlinkio/shlink-common": "^2.4", "shlinkio/shlink-common": "^2.5",
"shlinkio/shlink-event-dispatcher": "^1.1", "shlinkio/shlink-event-dispatcher": "^1.3",
"shlinkio/shlink-installer": "^3.3", "shlinkio/shlink-installer": "^4.0",
"shlinkio/shlink-ip-geolocation": "^1.2", "shlinkio/shlink-ip-geolocation": "^1.3",
"symfony/console": "^5.0", "symfony/console": "^5.0",
"symfony/filesystem": "^5.0", "symfony/filesystem": "^5.0",
"symfony/lock": "^5.0", "symfony/lock": "^5.0",
@ -64,7 +64,7 @@
"phpunit/phpunit": "^8.3", "phpunit/phpunit": "^8.3",
"roave/security-advisories": "dev-master", "roave/security-advisories": "dev-master",
"shlinkio/php-coding-standard": "~2.1.0", "shlinkio/php-coding-standard": "~2.1.0",
"shlinkio/shlink-test-utils": "^1.2", "shlinkio/shlink-test-utils": "^1.3",
"symfony/var-dumper": "^5.0" "symfony/var-dumper": "^5.0"
}, },
"autoload": { "autoload": {

View File

@ -2,51 +2,43 @@
declare(strict_types=1); declare(strict_types=1);
use Shlinkio\Shlink\Installer\Config\Plugin; use Shlinkio\Shlink\Installer\Config\Option;
return [ return [
'installer_plugins_expected_config' => [ 'installer' => [
Plugin\UrlShortenerConfigCustomizer::class => [ 'enabled_options' => [
Plugin\UrlShortenerConfigCustomizer::SCHEMA, Option\DatabaseDriverConfigOption::class,
Plugin\UrlShortenerConfigCustomizer::HOSTNAME, Option\DatabaseNameConfigOption::class,
Plugin\UrlShortenerConfigCustomizer::VALIDATE_URL, Option\DatabaseHostConfigOption::class,
Plugin\UrlShortenerConfigCustomizer::NOTIFY_VISITS_WEBHOOKS, Option\DatabasePortConfigOption::class,
Plugin\UrlShortenerConfigCustomizer::VISITS_WEBHOOKS, Option\DatabaseUserConfigOption::class,
Option\DatabasePasswordConfigOption::class,
Option\DatabaseSqlitePathConfigOption::class,
Option\DatabaseMySqlOptionsConfigOption::class,
Option\ShortDomainHostConfigOption::class,
Option\ShortDomainSchemaConfigOption::class,
Option\ValidateUrlConfigOption::class,
Option\VisitsWebhooksConfigOption::class,
Option\BaseUrlRedirectConfigOption::class,
Option\InvalidShortUrlRedirectConfigOption::class,
Option\Regular404RedirectConfigOption::class,
Option\DisableTrackParamConfigOption::class,
Option\CheckVisitsThresholdConfigOption::class,
Option\VisitsThresholdConfigOption::class,
Option\BasePathConfigOption::class,
Option\TaskWorkerNumConfigOption::class,
Option\WebWorkerNumConfigOption::class,
Option\RedisServersConfigOption::class,
], ],
Plugin\ApplicationConfigCustomizer::class => [ 'installation_commands' => [
Plugin\ApplicationConfigCustomizer::SECRET, 'db_create_schema' => [
Plugin\ApplicationConfigCustomizer::DISABLE_TRACK_PARAM, 'command' => 'bin/cli db:create',
Plugin\ApplicationConfigCustomizer::CHECK_VISITS_THRESHOLD, ],
Plugin\ApplicationConfigCustomizer::VISITS_THRESHOLD, 'db_migrate' => [
Plugin\ApplicationConfigCustomizer::BASE_PATH, 'command' => 'bin/cli db:migrate',
Plugin\ApplicationConfigCustomizer::WEB_WORKER_NUM, ],
Plugin\ApplicationConfigCustomizer::TASK_WORKER_NUM,
],
Plugin\DatabaseConfigCustomizer::class => [
Plugin\DatabaseConfigCustomizer::DRIVER,
Plugin\DatabaseConfigCustomizer::NAME,
Plugin\DatabaseConfigCustomizer::USER,
Plugin\DatabaseConfigCustomizer::PASSWORD,
Plugin\DatabaseConfigCustomizer::HOST,
Plugin\DatabaseConfigCustomizer::PORT,
],
Plugin\RedirectsConfigCustomizer::class => [
Plugin\RedirectsConfigCustomizer::INVALID_SHORT_URL_REDIRECT_TO,
Plugin\RedirectsConfigCustomizer::REGULAR_404_REDIRECT_TO,
Plugin\RedirectsConfigCustomizer::BASE_URL_REDIRECT_TO,
],
],
'installation_commands' => [
'db_create_schema' => [
'command' => 'bin/cli db:create',
],
'db_migrate' => [
'command' => 'bin/cli db:migrate',
], ],
], ],

View File

@ -1,13 +1,16 @@
<?php <?php
declare(strict_types=1); declare(strict_types=1);
return [ return [
'redis' => [ 'cache' => [
'servers' => 'tcp://shlink_redis:6379', 'redis' => [
// 'servers' => [ 'servers' => 'tcp://shlink_redis:6379',
// 'tcp://shlink_redis:6379', // 'servers' => [
// ], // 'tcp://shlink_redis:6379',
// ],
],
], ],
'dependencies' => [ 'dependencies' => [

View File

@ -5,7 +5,7 @@ declare(strict_types=1);
namespace ShlinkMigrations; namespace ShlinkMigrations;
use Doctrine\DBAL\Schema\Schema; use Doctrine\DBAL\Schema\Schema;
use Doctrine\DBAL\Types\Type; use Doctrine\DBAL\Types\Types;
use Doctrine\Migrations\AbstractMigration; use Doctrine\Migrations\AbstractMigration;
/** /**
@ -30,12 +30,12 @@ class Version20160820191203 extends AbstractMigration
private function createTagsTable(Schema $schema): void private function createTagsTable(Schema $schema): void
{ {
$table = $schema->createTable('tags'); $table = $schema->createTable('tags');
$table->addColumn('id', Type::BIGINT, [ $table->addColumn('id', Types::BIGINT, [
'unsigned' => true, 'unsigned' => true,
'autoincrement' => true, 'autoincrement' => true,
'notnull' => true, 'notnull' => true,
]); ]);
$table->addColumn('name', Type::STRING, [ $table->addColumn('name', Types::STRING, [
'length' => 255, 'length' => 255,
'notnull' => true, 'notnull' => true,
]); ]);
@ -47,11 +47,11 @@ class Version20160820191203 extends AbstractMigration
private function createShortUrlsInTagsTable(Schema $schema): void private function createShortUrlsInTagsTable(Schema $schema): void
{ {
$table = $schema->createTable('short_urls_in_tags'); $table = $schema->createTable('short_urls_in_tags');
$table->addColumn('short_url_id', Type::BIGINT, [ $table->addColumn('short_url_id', Types::BIGINT, [
'unsigned' => true, 'unsigned' => true,
'notnull' => true, 'notnull' => true,
]); ]);
$table->addColumn('tag_id', Type::BIGINT, [ $table->addColumn('tag_id', Types::BIGINT, [
'unsigned' => true, 'unsigned' => true,
'notnull' => true, 'notnull' => true,
]); ]);

View File

@ -6,7 +6,7 @@ namespace ShlinkMigrations;
use Doctrine\DBAL\Schema\Schema; use Doctrine\DBAL\Schema\Schema;
use Doctrine\DBAL\Schema\SchemaException; use Doctrine\DBAL\Schema\SchemaException;
use Doctrine\DBAL\Types\Type; use Doctrine\DBAL\Types\Types;
use Doctrine\Migrations\AbstractMigration; use Doctrine\Migrations\AbstractMigration;
/** /**
@ -24,10 +24,10 @@ class Version20171021093246 extends AbstractMigration
return; return;
} }
$shortUrls->addColumn('valid_since', Type::DATETIME, [ $shortUrls->addColumn('valid_since', Types::DATETIME, [
'notnull' => false, 'notnull' => false,
]); ]);
$shortUrls->addColumn('valid_until', Type::DATETIME, [ $shortUrls->addColumn('valid_until', Types::DATETIME, [
'notnull' => false, 'notnull' => false,
]); ]);
} }

View File

@ -6,7 +6,7 @@ namespace ShlinkMigrations;
use Doctrine\DBAL\Schema\Schema; use Doctrine\DBAL\Schema\Schema;
use Doctrine\DBAL\Schema\SchemaException; use Doctrine\DBAL\Schema\SchemaException;
use Doctrine\DBAL\Types\Type; use Doctrine\DBAL\Types\Types;
use Doctrine\Migrations\AbstractMigration; use Doctrine\Migrations\AbstractMigration;
/** /**
@ -24,7 +24,7 @@ class Version20171022064541 extends AbstractMigration
return; return;
} }
$shortUrls->addColumn('max_visits', Type::INTEGER, [ $shortUrls->addColumn('max_visits', Types::INTEGER, [
'unsigned' => true, 'unsigned' => true,
'notnull' => false, 'notnull' => false,
]); ]);

View File

@ -8,7 +8,7 @@ use Doctrine\DBAL\DBALException;
use Doctrine\DBAL\Schema\Schema; use Doctrine\DBAL\Schema\Schema;
use Doctrine\DBAL\Schema\SchemaException; use Doctrine\DBAL\Schema\SchemaException;
use Doctrine\DBAL\Schema\Table; use Doctrine\DBAL\Schema\Table;
use Doctrine\DBAL\Types\Type; use Doctrine\DBAL\Types\Types;
use Doctrine\Migrations\AbstractMigration; use Doctrine\Migrations\AbstractMigration;
/** /**
@ -35,7 +35,7 @@ final class Version20181020060559 extends AbstractMigration
{ {
foreach ($columnNames as $name) { foreach ($columnNames as $name) {
if (! $visitLocations->hasColumn($name)) { if (! $visitLocations->hasColumn($name)) {
$visitLocations->addColumn($name, Type::STRING, ['notnull' => false]); $visitLocations->addColumn($name, Types::STRING, ['notnull' => false]);
} }
} }
} }

View File

@ -6,7 +6,7 @@ namespace ShlinkMigrations;
use Doctrine\DBAL\Schema\Schema; use Doctrine\DBAL\Schema\Schema;
use Doctrine\DBAL\Schema\SchemaException; use Doctrine\DBAL\Schema\SchemaException;
use Doctrine\DBAL\Types\Type; use Doctrine\DBAL\Types\Types;
use Doctrine\Migrations\AbstractMigration; use Doctrine\Migrations\AbstractMigration;
final class Version20190930165521 extends AbstractMigration final class Version20190930165521 extends AbstractMigration
@ -22,19 +22,19 @@ final class Version20190930165521 extends AbstractMigration
} }
$domains = $schema->createTable('domains'); $domains = $schema->createTable('domains');
$domains->addColumn('id', Type::BIGINT, [ $domains->addColumn('id', Types::BIGINT, [
'unsigned' => true, 'unsigned' => true,
'autoincrement' => true, 'autoincrement' => true,
'notnull' => true, 'notnull' => true,
]); ]);
$domains->addColumn('authority', Type::STRING, [ $domains->addColumn('authority', Types::STRING, [
'length' => 512, 'length' => 512,
'notnull' => true, 'notnull' => true,
]); ]);
$domains->addUniqueIndex(['authority']); $domains->addUniqueIndex(['authority']);
$domains->setPrimaryKey(['id']); $domains->setPrimaryKey(['id']);
$shortUrls->addColumn('domain_id', Type::BIGINT, [ $shortUrls->addColumn('domain_id', Types::BIGINT, [
'unsigned' => true, 'unsigned' => true,
'notnull' => false, 'notnull' => false,
]); ]);

View File

@ -0,0 +1,71 @@
<?php
declare(strict_types=1);
namespace ShlinkMigrations;
use Doctrine\DBAL\DBALException;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\DBAL\Types\Types;
use Doctrine\Migrations\AbstractMigration;
final class Version20200105165647 extends AbstractMigration
{
private const COLUMNS = ['lat' => 'latitude', 'lon' => 'longitude'];
public function preUp(Schema $schema): void
{
foreach (self::COLUMNS as $columnName) {
$qb = $this->connection->createQueryBuilder();
$qb->update('visit_locations')
->set($columnName, '"0"')
->where($columnName . '=""')
->orWhere($columnName . ' IS NULL')
->execute();
}
}
/**
* @throws DBALException
*/
public function up(Schema $schema): void
{
$visitLocations = $schema->getTable('visit_locations');
foreach (self::COLUMNS as $newName => $oldName) {
$visitLocations->addColumn($newName, Types::FLOAT);
}
}
public function postUp(Schema $schema): void
{
foreach (self::COLUMNS as $newName => $oldName) {
$qb = $this->connection->createQueryBuilder();
$qb->update('visit_locations')
->set($newName, $oldName)
->execute();
}
}
public function preDown(Schema $schema): void
{
foreach (self::COLUMNS as $newName => $oldName) {
$qb = $this->connection->createQueryBuilder();
$qb->update('visit_locations')
->set($oldName, $newName)
->execute();
}
}
/**
* @throws DBALException
*/
public function down(Schema $schema): void
{
$visitLocations = $schema->getTable('visit_locations');
foreach (self::COLUMNS as $colName => $oldName) {
$visitLocations->dropColumn($colName);
}
}
}

View File

@ -0,0 +1,41 @@
<?php
declare(strict_types=1);
namespace ShlinkMigrations;
use Doctrine\DBAL\DBALException;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\DBAL\Types\Types;
use Doctrine\Migrations\AbstractMigration;
final class Version20200106215144 extends AbstractMigration
{
private const COLUMNS = ['latitude', 'longitude'];
/**
* @throws DBALException
*/
public function up(Schema $schema): void
{
$visitLocations = $schema->getTable('visit_locations');
foreach (self::COLUMNS as $colName) {
$visitLocations->dropColumn($colName);
}
}
/**
* @throws DBALException
*/
public function down(Schema $schema): void
{
$visitLocations = $schema->getTable('visit_locations');
foreach (self::COLUMNS as $colName) {
$visitLocations->addColumn($colName, Types::STRING, [
'notnull' => false,
]);
}
}
}

View File

@ -62,6 +62,12 @@ $helper = new class {
$webhooks = env('VISITS_WEBHOOKS'); $webhooks = env('VISITS_WEBHOOKS');
return $webhooks === null ? [] : explode(',', $webhooks); return $webhooks === null ? [] : explode(',', $webhooks);
} }
public function getRedisConfig(): ?array
{
$redisServers = env('REDIS_SERVERS');
return $redisServers === null ? null : ['servers' => $redisServers];
}
}; };
return [ return [
@ -112,8 +118,8 @@ return [
], ],
], ],
'redis' => [ 'cache' => [
'servers' => env('REDIS_SERVERS'), 'redis' => $helper->getRedisConfig(),
], ],
'router' => [ 'router' => [

View File

@ -4,7 +4,7 @@ declare(strict_types=1);
namespace Shlinkio\Shlink\Core; namespace Shlinkio\Shlink\Core;
use Doctrine\DBAL\Types\Type; use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping\Builder\ClassMetadataBuilder; use Doctrine\ORM\Mapping\Builder\ClassMetadataBuilder;
use Doctrine\ORM\Mapping\ClassMetadata; // @codingStandardsIgnoreLine use Doctrine\ORM\Mapping\ClassMetadata; // @codingStandardsIgnoreLine
@ -13,13 +13,13 @@ $builder = new ClassMetadataBuilder($metadata);
$builder->setTable('domains'); $builder->setTable('domains');
$builder->createField('id', Type::BIGINT) $builder->createField('id', Types::BIGINT)
->columnName('id') ->columnName('id')
->makePrimaryKey() ->makePrimaryKey()
->generatedValue('IDENTITY') ->generatedValue('IDENTITY')
->option('unsigned', true) ->option('unsigned', true)
->build(); ->build();
$builder->createField('authority', Type::STRING) $builder->createField('authority', Types::STRING)
->unique() ->unique()
->build(); ->build();

View File

@ -4,7 +4,7 @@ declare(strict_types=1);
namespace Shlinkio\Shlink\Core; namespace Shlinkio\Shlink\Core;
use Doctrine\DBAL\Types\Type; use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping\Builder\ClassMetadataBuilder; use Doctrine\ORM\Mapping\Builder\ClassMetadataBuilder;
use Doctrine\ORM\Mapping\ClassMetadata; // @codingStandardsIgnoreLine use Doctrine\ORM\Mapping\ClassMetadata; // @codingStandardsIgnoreLine
use Shlinkio\Shlink\Common\Doctrine\Type\ChronosDateTimeType; use Shlinkio\Shlink\Common\Doctrine\Type\ChronosDateTimeType;
@ -15,19 +15,19 @@ $builder = new ClassMetadataBuilder($metadata);
$builder->setTable('short_urls') $builder->setTable('short_urls')
->setCustomRepositoryClass(Repository\ShortUrlRepository::class); ->setCustomRepositoryClass(Repository\ShortUrlRepository::class);
$builder->createField('id', Type::BIGINT) $builder->createField('id', Types::BIGINT)
->columnName('id') ->columnName('id')
->makePrimaryKey() ->makePrimaryKey()
->generatedValue('IDENTITY') ->generatedValue('IDENTITY')
->option('unsigned', true) ->option('unsigned', true)
->build(); ->build();
$builder->createField('longUrl', Type::STRING) $builder->createField('longUrl', Types::STRING)
->columnName('original_url') ->columnName('original_url')
->length(2048) ->length(2048)
->build(); ->build();
$builder->createField('shortCode', Type::STRING) $builder->createField('shortCode', Types::STRING)
->columnName('short_code') ->columnName('short_code')
->length(255) ->length(255)
->build(); ->build();
@ -46,7 +46,7 @@ $builder->createField('validUntil', ChronosDateTimeType::CHRONOS_DATETIME)
->nullable() ->nullable()
->build(); ->build();
$builder->createField('maxVisits', Type::INTEGER) $builder->createField('maxVisits', Types::INTEGER)
->columnName('max_visits') ->columnName('max_visits')
->nullable() ->nullable()
->build(); ->build();

View File

@ -4,7 +4,7 @@ declare(strict_types=1);
namespace Shlinkio\Shlink\Core; namespace Shlinkio\Shlink\Core;
use Doctrine\DBAL\Types\Type; use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping\Builder\ClassMetadataBuilder; use Doctrine\ORM\Mapping\Builder\ClassMetadataBuilder;
use Doctrine\ORM\Mapping\ClassMetadata; // @codingStandardsIgnoreLine use Doctrine\ORM\Mapping\ClassMetadata; // @codingStandardsIgnoreLine
@ -14,13 +14,13 @@ $builder = new ClassMetadataBuilder($metadata);
$builder->setTable('tags') $builder->setTable('tags')
->setCustomRepositoryClass(Repository\TagRepository::class); ->setCustomRepositoryClass(Repository\TagRepository::class);
$builder->createField('id', Type::BIGINT) $builder->createField('id', Types::BIGINT)
->columnName('id') ->columnName('id')
->makePrimaryKey() ->makePrimaryKey()
->generatedValue('IDENTITY') ->generatedValue('IDENTITY')
->option('unsigned', true) ->option('unsigned', true)
->build(); ->build();
$builder->createField('name', Type::STRING) $builder->createField('name', Types::STRING)
->unique() ->unique()
->build(); ->build();

View File

@ -4,7 +4,7 @@ declare(strict_types=1);
namespace Shlinkio\Shlink\Core; namespace Shlinkio\Shlink\Core;
use Doctrine\DBAL\Types\Type; use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping\Builder\ClassMetadataBuilder; use Doctrine\ORM\Mapping\Builder\ClassMetadataBuilder;
use Doctrine\ORM\Mapping\ClassMetadata; // @codingStandardsIgnoreLine use Doctrine\ORM\Mapping\ClassMetadata; // @codingStandardsIgnoreLine
use Shlinkio\Shlink\Common\Doctrine\Type\ChronosDateTimeType; use Shlinkio\Shlink\Common\Doctrine\Type\ChronosDateTimeType;
@ -16,14 +16,14 @@ $builder = new ClassMetadataBuilder($metadata);
$builder->setTable('visits') $builder->setTable('visits')
->setCustomRepositoryClass(Repository\VisitRepository::class); ->setCustomRepositoryClass(Repository\VisitRepository::class);
$builder->createField('id', Type::BIGINT) $builder->createField('id', Types::BIGINT)
->columnName('id') ->columnName('id')
->makePrimaryKey() ->makePrimaryKey()
->generatedValue('IDENTITY') ->generatedValue('IDENTITY')
->option('unsigned', true) ->option('unsigned', true)
->build(); ->build();
$builder->createField('referer', Type::STRING) $builder->createField('referer', Types::STRING)
->nullable() ->nullable()
->length(Visitor::REFERER_MAX_LENGTH) ->length(Visitor::REFERER_MAX_LENGTH)
->build(); ->build();
@ -32,13 +32,13 @@ $builder->createField('date', ChronosDateTimeType::CHRONOS_DATETIME)
->columnName('`date`') ->columnName('`date`')
->build(); ->build();
$builder->createField('remoteAddr', Type::STRING) $builder->createField('remoteAddr', Types::STRING)
->columnName('remote_addr') ->columnName('remote_addr')
->length(Visitor::REMOTE_ADDRESS_MAX_LENGTH) ->length(Visitor::REMOTE_ADDRESS_MAX_LENGTH)
->nullable() ->nullable()
->build(); ->build();
$builder->createField('userAgent', Type::STRING) $builder->createField('userAgent', Types::STRING)
->columnName('user_agent') ->columnName('user_agent')
->length(Visitor::USER_AGENT_MAX_LENGTH) ->length(Visitor::USER_AGENT_MAX_LENGTH)
->nullable() ->nullable()

View File

@ -4,7 +4,7 @@ declare(strict_types=1);
namespace Shlinkio\Shlink\Core; namespace Shlinkio\Shlink\Core;
use Doctrine\DBAL\Types\Type; use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping\Builder\ClassMetadataBuilder; use Doctrine\ORM\Mapping\Builder\ClassMetadataBuilder;
use Doctrine\ORM\Mapping\ClassMetadata; // @codingStandardsIgnoreLine use Doctrine\ORM\Mapping\ClassMetadata; // @codingStandardsIgnoreLine
@ -13,7 +13,7 @@ $builder = new ClassMetadataBuilder($metadata);
$builder->setTable('visit_locations'); $builder->setTable('visit_locations');
$builder->createField('id', Type::BIGINT) $builder->createField('id', Types::BIGINT)
->columnName('id') ->columnName('id')
->makePrimaryKey() ->makePrimaryKey()
->generatedValue('IDENTITY') ->generatedValue('IDENTITY')
@ -25,14 +25,22 @@ $columns = [
'country_name' => 'countryName', 'country_name' => 'countryName',
'region_name' => 'regionName', 'region_name' => 'regionName',
'city_name' => 'cityName', 'city_name' => 'cityName',
'latitude' => 'latitude',
'longitude' => 'longitude',
'timezone' => 'timezone', 'timezone' => 'timezone',
]; ];
foreach ($columns as $columnName => $fieldName) { foreach ($columns as $columnName => $fieldName) {
$builder->createField($fieldName, Type::STRING) $builder->createField($fieldName, Types::STRING)
->columnName($columnName) ->columnName($columnName)
->nullable() ->nullable()
->build(); ->build();
} }
$builder->createField('latitude', Types::FLOAT)
->columnName('lat')
->nullable(false)
->build();
$builder->createField('longitude', Types::FLOAT)
->columnName('lon')
->nullable(false)
->build();

View File

@ -27,7 +27,7 @@ class SimplifiedConfigParser
'base_url_redirect_to' => ['not_found_redirects', 'base_path'], 'base_url_redirect_to' => ['not_found_redirects', 'base_path'],
'db_config' => ['entity_manager', 'connection'], 'db_config' => ['entity_manager', 'connection'],
'delete_short_url_threshold' => ['delete_short_urls', 'visits_threshold'], 'delete_short_url_threshold' => ['delete_short_urls', 'visits_threshold'],
'redis_servers' => ['redis', 'servers'], 'redis_servers' => ['cache', 'redis', 'servers'],
'base_path' => ['router', 'base_path'], 'base_path' => ['router', 'base_path'],
'web_worker_num' => ['mezzio-swoole', 'swoole-http-server', 'options', 'worker_num'], 'web_worker_num' => ['mezzio-swoole', 'swoole-http-server', 'options', 'worker_num'],
'task_worker_num' => ['mezzio-swoole', 'swoole-http-server', 'options', 'task_worker_num'], 'task_worker_num' => ['mezzio-swoole', 'swoole-http-server', 'options', 'task_worker_num'],

View File

@ -15,10 +15,10 @@ use Shlinkio\Shlink\Core\Visit\Model\VisitLocationInterface;
class Visit extends AbstractEntity implements JsonSerializable class Visit extends AbstractEntity implements JsonSerializable
{ {
private string $referer; private string $referer = '';
private Chronos $date; private Chronos $date;
private ?string $remoteAddr; private ?string $remoteAddr = null;
private string $userAgent; private string $userAgent = '';
private ShortUrl $shortUrl; private ShortUrl $shortUrl;
private ?VisitLocation $visitLocation = null; private ?VisitLocation $visitLocation = null;

View File

@ -97,10 +97,12 @@ class SimplifiedConfigParserTest extends TestCase
], ],
], ],
'redis' => [ 'cache' => [
'servers' => [ 'redis' => [
'tcp://1.1.1.1:1111', 'servers' => [
'tcp://1.2.2.2:2222', 'tcp://1.1.1.1:1111',
'tcp://1.2.2.2:2222',
],
], ],
], ],

View File

@ -4,7 +4,7 @@ declare(strict_types=1);
namespace Shlinkio\Shlink\Rest; namespace Shlinkio\Shlink\Rest;
use Doctrine\DBAL\Types\Type; use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping\Builder\ClassMetadataBuilder; use Doctrine\ORM\Mapping\Builder\ClassMetadataBuilder;
use Doctrine\ORM\Mapping\ClassMetadata; // @codingStandardsIgnoreLine use Doctrine\ORM\Mapping\ClassMetadata; // @codingStandardsIgnoreLine
use Shlinkio\Shlink\Common\Doctrine\Type\ChronosDateTimeType; use Shlinkio\Shlink\Common\Doctrine\Type\ChronosDateTimeType;
@ -14,13 +14,13 @@ $builder = new ClassMetadataBuilder($metadata);
$builder->setTable('api_keys'); $builder->setTable('api_keys');
$builder->createField('id', Type::BIGINT) $builder->createField('id', Types::BIGINT)
->makePrimaryKey() ->makePrimaryKey()
->generatedValue('IDENTITY') ->generatedValue('IDENTITY')
->option('unsigned', true) ->option('unsigned', true)
->build(); ->build();
$builder->createField('key', Type::STRING) $builder->createField('key', Types::STRING)
->columnName('`key`') ->columnName('`key`')
->unique() ->unique()
->build(); ->build();
@ -30,5 +30,5 @@ $builder->createField('expirationDate', ChronosDateTimeType::CHRONOS_DATETIME)
->nullable() ->nullable()
->build(); ->build();
$builder->createField('enabled', Type::BOOLEAN) $builder->createField('enabled', Types::BOOLEAN)
->build(); ->build();