From 0d9065ae80cf76bd9b0042fb9d2f1ecfc9e06fc9 Mon Sep 17 00:00:00 2001
From: Kim Alvefur <zash@zash.se>
Date: Tue, 30 Nov 2021 15:24:17 +0100
Subject: mod_storage_sql: Fix traceback on multi-user deletion

jid.join(true, ...) fails.

Since we don't know which users this affects, best to clear the whole
cache.
---
 plugins/mod_storage_sql.lua | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/plugins/mod_storage_sql.lua b/plugins/mod_storage_sql.lua
index f034a0eb..deafb005 100644
--- a/plugins/mod_storage_sql.lua
+++ b/plugins/mod_storage_sql.lua
@@ -624,8 +624,12 @@ function archive_store:delete(username, query)
 		end
 		return engine:delete(sql_query, unpack(args));
 	end);
-	local cache_key = jid_join(username, host, self.store);
-	archive_item_count_cache:set(cache_key, nil);
+	if username == true then
+		archive_item_count_cache:clear();
+	else
+		local cache_key = jid_join(username, host, self.store);
+		archive_item_count_cache:set(cache_key, nil);
+	end
 	return ok and stmt:affected(), stmt;
 end
 
-- 
cgit v1.2.3