Project

General

Profile

Bug #2651 » rrd.inc.patch

Norman Back, 10/28/2012 02:11 AM

View differences:

./b/etc/inc/rrd.inc 2012-10-25 21:58:33.514423782 +0100
147 147
		$rowcountold = count($rrdoldxml['rra'][$i]['database']['row']);
148 148
		$rowcountnew = count($rrdnewxml['rra'][$i]['database']['row']);
149 149
		$rowcountdiff = $rowcountnew - $rowcountold;
150
		/* save old rows for a bit before we put the required empty rows before it */
151
		$rowsdata = $rows;
152
		$rowsempty = array();
153
		$r = 0;
154
		while($r < $rowcountdiff) {
155
			$rowsempty[] = $rrdnewxml['rra'][$i]['database']['row'][$r];
156
			$r++;
150

  
151
		if($rowcountdiff < 0){
152
			/* remove excess rows */
153
			$r = - $rowcountdiff;
154
			$rrdoldxml['rra'][$i]['database']['row'] = array_slice($rrdoldxml['rra'][$i]['database']['row'],$r);
155
			$rowcountold = count($rrdoldxml['rra'][$i]['database']['row']);
156
			if($rowcountold == $rowcountnew){
157
				log_error(sprintf("Row count successfully reduced by $r to $rowcountold\n"));
158
			}
159
		}
160
		elseif($rowcountdiff > 0) {
161
			/* save old rows for a bit before we put the required empty rows before it */
162
			$rowsdata = $rows;
163
			$rowsempty = array();
164
			$r = 0;
165
			while($r < $rowcountdiff) {
166
				$rowsempty[] = $rrdnewxml['rra'][$i]['database']['row'][$r];
167
				$r++;
168
			}
169
			$rows = $rowsempty + $rowsdata;
157 170
		}
158
		$rows = $rowsempty + $rowsdata;
159 171
		/* now foreach the rows in the database */
160 172
		foreach($rows['row'] as $row) {
161 173
			if(!is_array($rrdoldxml['rra'][$i]['database']['row'][$k])) {
(2-2/2)