From: robert Date: Fri, 13 May 2005 19:40:26 +0000 (+0000) Subject: if eval returns nothing, leave array empty; in that case, don't update X-Git-Url: https://git-public.kairo.at/?a=commitdiff_plain;h=25b93a4dbffdb90f9dba75729b23176ab6fcdbe8;p=php-utility-classes.git if eval returns nothing, leave array empty; in that case, don't update --- diff --git a/include/classes/rrdstat.php-class b/include/classes/rrdstat.php-class index 6eed1bf..15cca53 100644 --- a/include/classes/rrdstat.php-class +++ b/include/classes/rrdstat.php-class @@ -154,7 +154,8 @@ class rrdstat { if (!is_null($evalcode)) { ob_start(); eval($evalcode); - $upvals = explode("\n", ob_get_contents()); + $ret = ob_get_contents(); + if (strlen($ret)) { $upvals = explode("\n", $ret); } ob_end_clean(); } $walkfunc = create_function('&$val,$key', '$val = is_numeric($val)?$val:"U";'); @@ -195,8 +196,11 @@ class rrdstat { $upvals[] = is_null($val)?'U':$val; } } - $update_cmd = 'rrdtool update '.$this->rrd_file.' N:'.implode(':', $upvals); - $return = `$update_cmd 2>&1`; + $return = null; + if (count($upvals)) { + $update_cmd = 'rrdtool update '.$this->rrd_file.' N:'.implode(':', $upvals); + $return = `$update_cmd 2>&1`; + } if (strpos($return, 'ERROR') !== false) { trigger_error($this->rrd_file.' - rrd update error: '.$return, E_USER_WARNING);