diff --git a/CHANGELOG.md b/CHANGELOG.md index 5eecc684..e5915375 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -28,6 +28,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com), and this * [#665](https://github.com/shlinkio/shlink/issues/665) Fixed `base_url_redirect_to` simplified config option not being properly parsed. * [#663](https://github.com/shlinkio/shlink/issues/663) Fixed Shlink allowing short URLs to be created with an empty custom slug. +* [#678](https://github.com/shlinkio/shlink/issues/678) Fixed `db` commands not running in a non-interactive way. ## 2.0.5 - 2020-02-09 diff --git a/README.md b/README.md index 7804af37..973a234b 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ [![Latest Stable Version](https://img.shields.io/github/release/shlinkio/shlink.svg?style=flat-square)](https://packagist.org/packages/shlinkio/shlink) [![Docker pulls](https://img.shields.io/docker/pulls/shlinkio/shlink.svg?style=flat-square)](https://hub.docker.com/r/shlinkio/shlink/) [![License](https://img.shields.io/github/license/shlinkio/shlink.svg?style=flat-square)](https://github.com/shlinkio/shlink/blob/master/LICENSE) -[![Paypal donate](https://img.shields.io/badge/Donate-paypal-blue.svg?style=flat-square&logo=paypal&colorA=aaaaaa)](https://acel.me/donate) +[![Paypal donate](https://img.shields.io/badge/Donate-paypal-blue.svg?style=flat-square&logo=paypal&colorA=aaaaaa)](https://slnk.to/donate) A PHP-based self-hosted URL shortener that can be used to serve shortened URLs under your own custom domain. diff --git a/composer.json b/composer.json index 84707645..5ee67a4d 100644 --- a/composer.json +++ b/composer.json @@ -49,10 +49,11 @@ "predis/predis": "^1.1", "pugx/shortid-php": "^0.5", "ramsey/uuid": "^3.9", - "shlinkio/shlink-common": "^2.8.0", - "shlinkio/shlink-event-dispatcher": "^1.3", - "shlinkio/shlink-installer": "^4.2.0", - "shlinkio/shlink-ip-geolocation": "^1.3.1", + "shlinkio/shlink-common": "^3.0", + "shlinkio/shlink-config": "^1.0", + "shlinkio/shlink-event-dispatcher": "^1.4", + "shlinkio/shlink-installer": "^4.3", + "shlinkio/shlink-ip-geolocation": "^1.4", "symfony/console": "^5.0", "symfony/filesystem": "^5.0", "symfony/lock": "^5.0", diff --git a/config/config.php b/config/config.php index 3fb1a3e4..98b4552b 100644 --- a/config/config.php +++ b/config/config.php @@ -19,11 +19,12 @@ return (new ConfigAggregator\ConfigAggregator([ Mezzio\Swoole\ConfigProvider::class, ProblemDetails\ConfigProvider::class, Common\ConfigProvider::class, + Config\ConfigProvider::class, IpGeolocation\ConfigProvider::class, + EventDispatcher\ConfigProvider::class, Core\ConfigProvider::class, CLI\ConfigProvider::class, Rest\ConfigProvider::class, - EventDispatcher\ConfigProvider::class, new ConfigAggregator\PhpFileProvider('config/autoload/{{,*.}global,{,*.}local}.php'), env('APP_ENV') === 'test' ? new ConfigAggregator\PhpFileProvider('config/test/*.global.php') diff --git a/module/CLI/src/Command/Db/AbstractDatabaseCommand.php b/module/CLI/src/Command/Db/AbstractDatabaseCommand.php index 4b45fa56..5e9374cf 100644 --- a/module/CLI/src/Command/Db/AbstractDatabaseCommand.php +++ b/module/CLI/src/Command/Db/AbstractDatabaseCommand.php @@ -11,8 +11,6 @@ use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Lock\LockFactory; use Symfony\Component\Process\PhpExecutableFinder; -use function array_unshift; - abstract class AbstractDatabaseCommand extends AbstractLockedCommand { private ProcessHelper $processHelper; @@ -27,7 +25,7 @@ abstract class AbstractDatabaseCommand extends AbstractLockedCommand protected function runPhpCommand(OutputInterface $output, array $command): void { - array_unshift($command, $this->phpBinary); + $command = [$this->phpBinary, ...$command, '--no-interaction']; $this->processHelper->mustRun($output, $command); } diff --git a/module/CLI/src/ConfigProvider.php b/module/CLI/src/ConfigProvider.php index 40dcf775..8155b68b 100644 --- a/module/CLI/src/ConfigProvider.php +++ b/module/CLI/src/ConfigProvider.php @@ -4,7 +4,7 @@ declare(strict_types=1); namespace Shlinkio\Shlink\CLI; -use function Shlinkio\Shlink\Common\loadConfigFromGlob; +use function Shlinkio\Shlink\Config\loadConfigFromGlob; class ConfigProvider { diff --git a/module/CLI/test/Command/Db/CreateDatabaseCommandTest.php b/module/CLI/test/Command/Db/CreateDatabaseCommandTest.php index c88e28fa..d890f264 100644 --- a/module/CLI/test/Command/Db/CreateDatabaseCommandTest.php +++ b/module/CLI/test/Command/Db/CreateDatabaseCommandTest.php @@ -18,6 +18,7 @@ use Symfony\Component\Console\Tester\CommandTester; use Symfony\Component\Lock\LockFactory; use Symfony\Component\Lock\LockInterface; use Symfony\Component\Process\PhpExecutableFinder; +use Symfony\Component\Process\Process; class CreateDatabaseCommandTest extends TestCase { @@ -114,7 +115,8 @@ class CreateDatabaseCommandTest extends TestCase '/usr/local/bin/php', CreateDatabaseCommand::DOCTRINE_SCRIPT, CreateDatabaseCommand::DOCTRINE_CREATE_SCHEMA_COMMAND, - ], Argument::cetera()); + '--no-interaction', + ], Argument::cetera())->willReturn(new Process([])); $this->commandTester->execute([]); $output = $this->commandTester->getDisplay(); diff --git a/module/CLI/test/Command/Db/MigrateDatabaseCommandTest.php b/module/CLI/test/Command/Db/MigrateDatabaseCommandTest.php index 15f756a7..71587eea 100644 --- a/module/CLI/test/Command/Db/MigrateDatabaseCommandTest.php +++ b/module/CLI/test/Command/Db/MigrateDatabaseCommandTest.php @@ -15,6 +15,7 @@ use Symfony\Component\Console\Tester\CommandTester; use Symfony\Component\Lock\LockFactory; use Symfony\Component\Lock\LockInterface; use Symfony\Component\Process\PhpExecutableFinder; +use Symfony\Component\Process\Process; class MigrateDatabaseCommandTest extends TestCase { @@ -53,7 +54,8 @@ class MigrateDatabaseCommandTest extends TestCase '/usr/local/bin/php', MigrateDatabaseCommand::DOCTRINE_MIGRATIONS_SCRIPT, MigrateDatabaseCommand::DOCTRINE_MIGRATE_COMMAND, - ], Argument::cetera()); + '--no-interaction', + ], Argument::cetera())->willReturn(new Process([])); $this->commandTester->execute([]); $output = $this->commandTester->getDisplay(); diff --git a/module/Core/src/Config/SimplifiedConfigParser.php b/module/Core/src/Config/SimplifiedConfigParser.php index 6181e27a..ee29d195 100644 --- a/module/Core/src/Config/SimplifiedConfigParser.php +++ b/module/Core/src/Config/SimplifiedConfigParser.php @@ -5,7 +5,7 @@ declare(strict_types=1); namespace Shlinkio\Shlink\Core\Config; use Laminas\Stdlib\ArrayUtils; -use Shlinkio\Shlink\Installer\Util\PathCollection; +use Shlinkio\Shlink\Config\Collection\PathCollection; use function array_flip; use function array_intersect_key; diff --git a/module/Core/src/ConfigProvider.php b/module/Core/src/ConfigProvider.php index 086d093d..2c130ea9 100644 --- a/module/Core/src/ConfigProvider.php +++ b/module/Core/src/ConfigProvider.php @@ -4,7 +4,7 @@ declare(strict_types=1); namespace Shlinkio\Shlink\Core; -use function Shlinkio\Shlink\Common\loadConfigFromGlob; +use function Shlinkio\Shlink\Config\loadConfigFromGlob; class ConfigProvider { diff --git a/module/Core/test/Model/VisitorTest.php b/module/Core/test/Model/VisitorTest.php index 9aa928a8..0a0c1828 100644 --- a/module/Core/test/Model/VisitorTest.php +++ b/module/Core/test/Model/VisitorTest.php @@ -5,16 +5,15 @@ declare(strict_types=1); namespace ShlinkioTest\Shlink\Core\Model; use PHPUnit\Framework\TestCase; -use Shlinkio\Shlink\Common\Util\StringUtilsTrait; use Shlinkio\Shlink\Core\Model\Visitor; +use function random_int; use function str_repeat; +use function strlen; use function substr; class VisitorTest extends TestCase { - use StringUtilsTrait; - /** * @test * @dataProvider provideParams @@ -60,4 +59,15 @@ class VisitorTest extends TestCase ], ]; } + + private function generateRandomString(int $length): string + { + $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; + $charactersLength = strlen($characters); + $randomString = ''; + for ($i = 0; $i < $length; $i++) { + $randomString .= $characters[random_int(0, $charactersLength - 1)]; + } + return $randomString; + } } diff --git a/module/Rest/src/ConfigProvider.php b/module/Rest/src/ConfigProvider.php index 570eab85..130617d6 100644 --- a/module/Rest/src/ConfigProvider.php +++ b/module/Rest/src/ConfigProvider.php @@ -8,7 +8,7 @@ use Closure; use function Functional\first; use function Functional\map; -use function Shlinkio\Shlink\Common\loadConfigFromGlob; +use function Shlinkio\Shlink\Config\loadConfigFromGlob; use function sprintf; class ConfigProvider