From 8a432ac93776f01a5464f70e7d34e223193aad2e Mon Sep 17 00:00:00 2001 From: Ionys <9364594+Ionys320@users.noreply.github.com> Date: Tue, 12 Nov 2024 19:00:09 +0100 Subject: [PATCH] fix(status page): Make sure the group deletion is correctly handled when `groupIDList` is empty (#5340) --- .../status-page-socket-handler.js | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/server/socket-handlers/status-page-socket-handler.js b/server/socket-handlers/status-page-socket-handler.js index 0804da15..cbcc52b8 100644 --- a/server/socket-handlers/status-page-socket-handler.js +++ b/server/socket-handlers/status-page-socket-handler.js @@ -220,13 +220,17 @@ module.exports.statusPageSocketHandler = (socket) => { // Delete groups that are not in the list log.debug("socket", "Delete groups that are not in the list"); - const slots = groupIDList.map(() => "?").join(","); + if (groupIDList.length === 0) { + await R.exec("DELETE FROM `group` WHERE status_page_id = ?", [ statusPage.id ]); + } else { + const slots = groupIDList.map(() => "?").join(","); - const data = [ - ...groupIDList, - statusPage.id - ]; - await R.exec(`DELETE FROM \`group\` WHERE id NOT IN (${slots}) AND status_page_id = ?`, data); + const data = [ + ...groupIDList, + statusPage.id + ]; + await R.exec(`DELETE FROM \`group\` WHERE id NOT IN (${slots}) AND status_page_id = ?`, data); + } const server = UptimeKumaServer.getInstance();