From d7eb39c88e09eb71a63c5c5c4f26f40f9bf6fb88 Mon Sep 17 00:00:00 2001 From: webplusai Date: Thu, 5 Dec 2024 13:29:58 +0100 Subject: [PATCH] #8776 resolve server crash on delete role in use (#8796) --- .../multiwikiserver/modules/routes/handlers/delete-role.js | 5 ++--- .../multiwikiserver/modules/store/sql-tiddler-database.js | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/plugins/tiddlywiki/multiwikiserver/modules/routes/handlers/delete-role.js b/plugins/tiddlywiki/multiwikiserver/modules/routes/handlers/delete-role.js index 43fa1aa6f..571545b15 100644 --- a/plugins/tiddlywiki/multiwikiserver/modules/routes/handlers/delete-role.js +++ b/plugins/tiddlywiki/multiwikiserver/modules/routes/handlers/delete-role.js @@ -38,15 +38,14 @@ POST /admin/delete-role return; } - // Delete the role - sqlTiddlerDatabase.deleteRole(role_id); - // Check if the role is in use var isRoleInUse = sqlTiddlerDatabase.isRoleInUse(role_id); if(isRoleInUse) { sqlTiddlerDatabase.deleteUserRolesByRoleId(role_id); } + // Delete the role + sqlTiddlerDatabase.deleteRole(role_id); // Redirect back to the roles management page response.writeHead(302, { "Location": "/admin/roles" }); response.end(); diff --git a/plugins/tiddlywiki/multiwikiserver/modules/store/sql-tiddler-database.js b/plugins/tiddlywiki/multiwikiserver/modules/store/sql-tiddler-database.js index d56f12eab..bd78301e1 100644 --- a/plugins/tiddlywiki/multiwikiserver/modules/store/sql-tiddler-database.js +++ b/plugins/tiddlywiki/multiwikiserver/modules/store/sql-tiddler-database.js @@ -1156,7 +1156,7 @@ SqlTiddlerDatabase.prototype.deleteRole = function(roleId) { SqlTiddlerDatabase.prototype.listRoles = function() { return this.engine.runStatementGetAll(` - SELECT * FROM roles ORDER BY role_name + SELECT * FROM roles ORDER BY role_name DESC `); };