Skip to content
This repository was archived by the owner on Apr 20, 2020. It is now read-only.

Commit 8b9f2fc

Browse files
author
mrcrankhank
committed
Fix bug in parser
1 parent 1fe79e1 commit 8b9f2fc

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ Will be added once version 0.6 is released
2121
Take a look at the github releases for detailed information about the features.
2222

2323
## Bugs in 0.5.6:
24-
- [ ] Parse function could overwrite comments
24+
- [x] Parse function could overwrite comments
2525
- [x] Fix phpietadmin login user menu
2626
- [x] The same object can be added multiple times to a iqn
2727

app/models/target/Parser.php

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,9 +123,20 @@ public function parse_file($filename, callable $callback, array $params, $return
123123
// so we just add a index to the key array
124124
// multiple keys are only handled in delete functions
125125
// there is no function which adds multiple lines
126-
$file_keys[] = max($file_keys) + 1;
126+
if (count($file_keys) === 0) {
127+
if (isset($comments) && is_array($comments)) {
128+
$file_keys[] = count($comments) + 1;
129+
} else {
130+
$file_keys[] = 1;
131+
}
132+
} else {
133+
if (isset($comments) && is_array($comments)) {
134+
$file_keys[] = $callback_data_count + count($comments) + 1;
135+
} else {
136+
$file_keys[] = $callback_data_count + 1;
137+
}
138+
}
127139
}
128-
129140
$file = array_combine($file_keys, $callback_data['file']);
130141
}
131142

0 commit comments

Comments
 (0)