Author: Lars Michelsen <[email protected]>
Date: Sat Sep 24 01:34:54 2011 +0200
Committer: Lars Michelsen <[email protected]>
Commit-Date: Sat Sep 24 01:34:54 2011 +0200
Fixed attribute adding/deletion bug
---
share/server/core/classes/GlobalMapCfg.php | 21 ++++++++++-----------
1 files changed, 10 insertions(+), 11 deletions(-)
diff --git a/share/server/core/classes/GlobalMapCfg.php
b/share/server/core/classes/GlobalMapCfg.php
index 043f624..05730fb 100644
--- a/share/server/core/classes/GlobalMapCfg.php
+++ b/share/server/core/classes/GlobalMapCfg.php
@@ -990,7 +990,6 @@ class GlobalMapCfg {
list($inObj, $start, $end) = $this->getObjectLinesByNum(0);
else
list($inObj, $start, $end) = $this->getObjectLinesById($id);
-
// Remove object head/foot
$start += 1;
$end -= 1;
@@ -1002,11 +1001,13 @@ class GlobalMapCfg {
// Loop all object lines from file to remove all parameters which can
not be
// found in the current array anymore
- for($i = $start; $i < $end; $i++) {
+ for($i = $end; $i >= $start; $i--) {
$entry = explode('=', $f[$i], 2);
$key = trim($entry[0]);
- if(!isset($this->mapConfig[$id][$key]))
+ if(!isset($this->mapConfig[$id][$key])) {
array_splice($f, $i, 1);
+ $end -= 1;
+ }
}
// Loop all parameters from array
@@ -1018,7 +1019,7 @@ class GlobalMapCfg {
continue;
// Search for the param in the map config
- for($i = $start; $i < $end; $i++) {
+ for($i = $start; $i <= $end; $i++) {
$entry = explode('=', $f[$i], 2);
// Skip non matching keys
@@ -1033,16 +1034,14 @@ class GlobalMapCfg {
$newLine = $key.'='.$val."\n";
- if($lineNum !== null && $newLine !== '')
+ if($lineNum !== null && $newLine !== '') {
// if a parameter was found in file and value is not empty,
replace line
$f[$lineNum] = $newLine;
- elseif($lineNum !== null && $newLine === '') {
- // if a paremter is not in array or a value is empty, delete
the line in the file
- // FIXME: Never reached here? But should be handled by
separate loop above
- array_splice($f, $lineNum, 1);
- } elseif($lineNum === null && $newLine !== '')
+ } elseif($lineNum === null && $newLine !== '') {
// if a parameter was not found in array and a value is not
empty, create line
- array_splice($f, $end, 0, Array($newLine));
+ array_splice($f, $end + 1, 0, Array($newLine));
+ $end += 1;
+ }
}
$this->writeConfig($f);
------------------------------------------------------------------------------
All of the data generated in your IT infrastructure is seriously valuable.
Why? It contains a definitive record of application performance, security
threats, fraudulent activity, and more. Splunk takes this data and makes
sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-d2dcopy2
_______________________________________________
Nagvis-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/nagvis-checkins