Skip to content

Commit 2fb9d14

Browse files
fix(mactrack): address Copilot review on site_scan --web flag and error surfacing
Make --web conditional on $web param in mactrack_site_scan (was always added). Append subprocess exit-code errors to data['content'] so the AJAX client shows failures rather than an empty dialog. Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
1 parent 8f2040c commit 2fb9d14

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

lib/mactrack_functions.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3145,7 +3145,8 @@ function mactrack_rescan($web = false) {
31453145
$data['content'] = ob_get_clean();
31463146

31473147
if ($exit_code !== 0) {
3148-
$data['error'] = 'rescan process exited with code ' . intval($exit_code);
3148+
$data['error'] = 'rescan process exited with code ' . intval($exit_code);
3149+
$data['content'] .= '<p class="textError">' . html_escape('Subprocess error: exit code ' . intval($exit_code)) . '</p>';
31493150
}
31503151
}
31513152
}
@@ -3175,7 +3176,7 @@ function mactrack_site_scan($web = false) {
31753176

31763177
// create the command script
31773178
$command_string = $config['base_path'] . '/plugins/mactrack/poller_mactrack.php';
3178-
$extra_args = ' --web -sid=' . cacti_escapeshellarg($dbinfo['site_id']);
3179+
$extra_args = ' -sid=' . cacti_escapeshellarg($dbinfo['site_id']) . ($web ? ' --web' : '');
31793180

31803181
// print out the type, and device_id
31813182
$data['site_id'] = $site_id;
@@ -3190,7 +3191,8 @@ function mactrack_site_scan($web = false) {
31903191
$data['content'] = ob_get_clean();
31913192

31923193
if ($exit_code !== 0) {
3193-
$data['error'] = 'site_scan process exited with code ' . intval($exit_code);
3194+
$data['error'] = 'site_scan process exited with code ' . intval($exit_code);
3195+
$data['content'] .= '<p class="textError">' . html_escape('Subprocess error: exit code ' . intval($exit_code)) . '</p>';
31943196
}
31953197
}
31963198

0 commit comments

Comments
 (0)