From 83c0c672d483a3dd9e97ec9e17226374f5173e79 Mon Sep 17 00:00:00 2001 From: Laurent Laville Date: Mon, 19 Apr 2021 17:27:20 +0200 Subject: [PATCH] avoid PHP Fatal Error when pgsql PHP module is not available --- .devilbox/www/include/lib/container/Pgsql.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/.devilbox/www/include/lib/container/Pgsql.php b/.devilbox/www/include/lib/container/Pgsql.php index 14832ed3..713aab44 100644 --- a/.devilbox/www/include/lib/container/Pgsql.php +++ b/.devilbox/www/include/lib/container/Pgsql.php @@ -38,6 +38,11 @@ class Pgsql extends BaseClass implements BaseInterface { parent::__construct($hostname, $data); + // Faster check if pgsql is not loaded + if (!$this->isAvailable()) { + return; + } + $user = $data['user']; $pass = $data['pass']; $db = isset($data['db']) ? $data['db'] : null; @@ -372,4 +377,14 @@ class Pgsql extends BaseClass implements BaseInterface return $this->_version; } + + public function isAvailable() + { + if (extension_loaded('pgsql')) { + return parent::isAvailable(); + } + + // when php module 'pgsql' not available or just disable by configuration (see .env PHP_MODULES_DISABLE) + return false; + } }