refactor redundant code (#31331)

This commit is contained in:
hansemschnokeloch
2024-10-13 19:38:38 +02:00
committed by GitHub
parent e63fcc9fed
commit 6ba48c5db2

View File

@@ -10589,27 +10589,15 @@ function dol_eval($s, $returnvalue = 1, $hideerrors = 1, $onlysimplestring = '1'
//print $s."<br>\n";
if ($returnvalue) {
if ($hideerrors) {
ob_start(); // An evaluation has no reason to output data
$isObBufferActive = true;
$tmps = @eval('return '.$s.';');
$tmpo = ob_get_clean();
$isObBufferActive = false;
if ($tmpo) {
print 'Bad string syntax to evaluate. Some data were output when it should not when evaluating: '.$s;
}
return $tmps;
} else {
ob_start(); // An evaluation has no reason to output data
$isObBufferActive = true;
$tmps = eval('return '.$s.';');
$tmpo = ob_get_clean();
$isObBufferActive = false;
if ($tmpo) {
print 'Bad string syntax to evaluate. Some data were output when it should not when evaluating: '.$s;
}
return $tmps;
ob_start(); // An evaluation has no reason to output data
$isObBufferActive = true;
$tmps = $hideerrors ? @eval('return ' . $s . ';') : eval('return ' . $s . ';');
$tmpo = ob_get_clean();
$isObBufferActive = false;
if ($tmpo) {
print 'Bad string syntax to evaluate. Some data were output when it should not when evaluating: ' . $s;
}
return $tmps;
} else {
dol_syslog('Do not use anymore dol_eval with param returnvalue=0', LOG_WARNING);
if ($hideerrors) {