Merge pull request #16648 from frederic34/php8-fix
fix php8 fatal error
This commit is contained in:
commit
cb9d661158
@ -93,7 +93,7 @@ function dol_setcache($memoryid, $data, $expire = 0)
|
|||||||
$dolmemcache->add($memoryid, $data, $expire); // This fails if key already exists
|
$dolmemcache->add($memoryid, $data, $expire); // This fails if key already exists
|
||||||
$rescode = $dolmemcache->getResultCode();
|
$rescode = $dolmemcache->getResultCode();
|
||||||
if ($rescode == 0) {
|
if ($rescode == 0) {
|
||||||
return count($data);
|
return is_countable($data) ? count($data) : 0;
|
||||||
} else {
|
} else {
|
||||||
return -$rescode;
|
return -$rescode;
|
||||||
}
|
}
|
||||||
@ -113,7 +113,7 @@ function dol_setcache($memoryid, $data, $expire = 0)
|
|||||||
//$dolmemcache->setOption(Memcached::OPT_COMPRESSION, false);
|
//$dolmemcache->setOption(Memcached::OPT_COMPRESSION, false);
|
||||||
$result = $dolmemcache->add($memoryid, $data, false, $expire); // This fails if key already exists
|
$result = $dolmemcache->add($memoryid, $data, false, $expire); // This fails if key already exists
|
||||||
if ($result) {
|
if ($result) {
|
||||||
return count($data);
|
return is_countable($data) ? count($data) : 0;
|
||||||
} else {
|
} else {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -35,6 +35,17 @@
|
|||||||
require_once 'filefunc.inc.php'; // May have been already require by main.inc.php. But may not by scripts.
|
require_once 'filefunc.inc.php'; // May have been already require by main.inc.php. But may not by scripts.
|
||||||
|
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Create $conf object
|
* Create $conf object
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user