Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions setup.php
Original file line number Diff line number Diff line change
Expand Up @@ -319,9 +319,9 @@ function monitor_device_action_execute($action) {
}

function monitor_device_remove($devices) {
db_execute('DELETE FROM plugin_monitor_notify_history WHERE host_id IN(' . implode(',', $devices) . ')');
db_execute('DELETE FROM plugin_monitor_reboot_history WHERE host_id IN(' . implode(',', $devices) . ')');
db_execute('DELETE FROM plugin_monitor_uptime WHERE host_id IN(' . implode(',', $devices) . ')');
db_execute_prepared('DELETE FROM plugin_monitor_notify_history WHERE host_id IN(' . implode(',', array_fill(0, cacti_count($devices), '?')) . ')', array_values(array_map('intval', $devices)));
db_execute_prepared('DELETE FROM plugin_monitor_reboot_history WHERE host_id IN(' . implode(',', array_fill(0, cacti_count($devices), '?')) . ')', array_values(array_map('intval', $devices)));
db_execute_prepared('DELETE FROM plugin_monitor_uptime WHERE host_id IN(' . implode(',', array_fill(0, cacti_count($devices), '?')) . ')', array_values(array_map('intval', $devices)));
Comment on lines +322 to +324
Copy link

Copilot AI Apr 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These three DELETEs duplicate the same placeholder and parameter list construction. Consider computing $deviceIds once (sanitized/reindexed) and deriving the IN placeholder string from that array, then reuse for all three queries; it reduces repetition and avoids any risk of placeholder/param count drift if the sanitization logic changes.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Valid DRY opportunity. Will extract to a helper in a follow-up.


return $devices;
}
Expand Down
Loading