avoid PHP Fatal Error when pgsql PHP module is not available

This commit is contained in:
Laurent Laville 2021-04-19 17:27:20 +02:00
parent af68fb65f2
commit 83c0c672d4

View File

@ -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;
}
}