fix php8 fatal error
This commit is contained in:
parent
99461b3fa6
commit
c3c03e9de3
@ -93,7 +93,7 @@ function dol_setcache($memoryid, $data, $expire = 0)
|
||||
$dolmemcache->add($memoryid, $data, $expire); // This fails if key already exists
|
||||
$rescode = $dolmemcache->getResultCode();
|
||||
if ($rescode == 0) {
|
||||
return count($data);
|
||||
return is_countable($data) ? count($data) : 0;
|
||||
} else {
|
||||
return -$rescode;
|
||||
}
|
||||
@ -113,7 +113,7 @@ function dol_setcache($memoryid, $data, $expire = 0)
|
||||
//$dolmemcache->setOption(Memcached::OPT_COMPRESSION, false);
|
||||
$result = $dolmemcache->add($memoryid, $data, false, $expire); // This fails if key already exists
|
||||
if ($result) {
|
||||
return count($data);
|
||||
return is_countable($data) ? count($data) : 0;
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -48,6 +48,18 @@ if (!empty($_SERVER['MAIN_SHOW_TUNING_INFO'])) {
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('is_countable')) {
|
||||
/**
|
||||
* function is_countable (to remove when php version supported will be >= 7.3)
|
||||
* @param mixed $c data to check if countable
|
||||
* @return bool
|
||||
*/
|
||||
function is_countable($c)
|
||||
{
|
||||
return is_array($c) || $c instanceof Countable;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Security: WAF layer for SQL Injection and XSS Injection (scripts) protection (Filters on GET, POST, PHP_SELF).
|
||||
* Warning: Such a protection can't be enough. It is not reliable as it will alwyas be possible to bypass this. Good protection can
|
||||
|
||||
Loading…
Reference in New Issue
Block a user