From 2c688daf2a93dfd0b3ed02790e32b9f6f05a5672 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20L=C5=93uillet?= Date: Wed, 19 Jul 2023 15:33:56 +0200 Subject: [PATCH] Fix installer when database not exists --- src/Wallabag/CoreBundle/Command/InstallCommand.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/Wallabag/CoreBundle/Command/InstallCommand.php b/src/Wallabag/CoreBundle/Command/InstallCommand.php index 64ea1c229..ad619312a 100644 --- a/src/Wallabag/CoreBundle/Command/InstallCommand.php +++ b/src/Wallabag/CoreBundle/Command/InstallCommand.php @@ -372,24 +372,25 @@ class InstallCommand extends Command private function isDatabasePresent() { $connection = $this->entityManager->getConnection(); - $databaseName = $connection->getDatabase(); try { - $schemaManager = $connection->getSchemaManager(); + $databaseName = $connection->getDatabase(); } catch (\Exception $exception) { // mysql & sqlite - if (false !== strpos($exception->getMessage(), sprintf("Unknown database '%s'", $databaseName))) { + if (false !== strpos($exception->getMessage(), 'Unknown database')) { return false; } // pgsql - if (false !== strpos($exception->getMessage(), sprintf('database "%s" does not exist', $databaseName))) { + if (false !== strpos($exception->getMessage(), 'does not exist')) { return false; } throw $exception; } + $schemaManager = $connection->getSchemaManager(); + // custom verification for sqlite, since `getListDatabasesSQL` doesn't work for sqlite if ('sqlite' === $schemaManager->getDatabasePlatform()->getName()) { $params = $connection->getParams();