mirror of
https://github.com/cytopia/devilbox.git
synced 2025-02-20 17:33:05 +00:00
avoid PHP Fatal Error when memcache PHP modules are not available
This commit is contained in:
parent
46f5c48ba0
commit
f6c273d6c4
@ -37,6 +37,11 @@ class Memcd extends BaseClass implements BaseInterface
|
||||
{
|
||||
parent::__construct($hostname, $data);
|
||||
|
||||
// Faster check if memcached is not loaded
|
||||
if (!$this->isAvailable()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (class_exists('Memcached')) {
|
||||
$memcd = new \Memcached('_devilbox');
|
||||
$list = $memcd->getServerList();
|
||||
@ -274,4 +279,14 @@ class Memcd extends BaseClass implements BaseInterface
|
||||
}
|
||||
return $this->_version;
|
||||
}
|
||||
|
||||
public function isAvailable()
|
||||
{
|
||||
if (extension_loaded('memcached')) {
|
||||
return parent::isAvailable();
|
||||
}
|
||||
|
||||
// when php module 'memcached' not available or just disable by configuration (see .env PHP_MODULES_DISABLE)
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user