From: Johan Cwiklinski Date: Sun, 12 Mar 2023 10:02:43 +0000 (+0100) Subject: Fix display issue on connection failure X-Git-Tag: 1.0.0rc1~56 X-Git-Url: https://git.agnieray.net/?a=commitdiff_plain;h=ea6d8f00e448130d8e87c6c9d07cb04043dcedb9;p=galette.git Fix display issue on connection failure Fix error message --- diff --git a/galette/install/steps/db_checks.php b/galette/install/steps/db_checks.php index 9cf1965a6..0c456ea19 100644 --- a/galette/install/steps/db_checks.php +++ b/galette/install/steps/db_checks.php @@ -37,7 +37,11 @@ use Galette\Core\Install as GaletteInstall; use Galette\Core\Db as GaletteDb; -$db_connected = $install->testDbConnexion(); +try { + $db_connected = $install->testDbConnexion(); +} catch (Throwable $e) { + $db_connected = $e; +} $conndb_ok = true; $permsdb_ok = true; @@ -192,7 +196,6 @@ if ($db_connected !== true) { echo '
'; echo '
' . _T("Unable to connect to the database") . '
'; echo '

' . $db_connected->getMessage() . '

'; - echo '
' . $db_connected->getTraceAsString() . '
'; echo '
'; } @@ -231,12 +234,14 @@ if (!$conndb_ok) { } ?> + -
diff --git a/galette/lib/Galette/Core/Db.php b/galette/lib/Galette/Core/Db.php index 981a5acd4..e77ac2f8b 100644 --- a/galette/lib/Galette/Core/Db.php +++ b/galette/lib/Galette/Core/Db.php @@ -277,6 +277,8 @@ class Db * @param string $db database name * * @return true + * + * @throws \Exception|Throwable */ public static function testConnectivity( $type, @@ -286,14 +288,13 @@ class Db $port = null, $db = null ) { - $_type = null; try { if ($type === self::MYSQL) { $_type = 'Pdo_Mysql'; } elseif ($type === self::PGSQL) { $_type = 'Pdo_Pgsql'; } else { - throw new \Exception(); + throw new \Exception('Unknown database type'); } $_options = array( diff --git a/galette/lib/Galette/Core/Install.php b/galette/lib/Galette/Core/Install.php index e4ba9a8ff..82e874fe3 100644 --- a/galette/lib/Galette/Core/Install.php +++ b/galette/lib/Galette/Core/Install.php @@ -452,8 +452,9 @@ class Install /** * Test database connection * - * @return true|array true if connection was successfull, - * an array with some infos otherwise + * @return true + * + * @throws \Exception */ public function testDbConnexion() {