Skip to content

Node.js based forum software built for the modern web

fix: upgrade script to handle topics that were already pruned

Barış Soner Uşaklı03b7374c69b7
diff --git a/src/upgrades/4.8.2/clean_ap_tids_from_topic_zsets.js b/src/upgrades/4.8.2/clean_ap_tids_from_topic_zsets.js
index d598ba1e80..547dd14157 100644
--- a/src/upgrades/4.8.2/clean_ap_tids_from_topic_zsets.js
+++ b/src/upgrades/4.8.2/clean_ap_tids_from_topic_zsets.js
@@ -17,10 +17,16 @@ module.exports = {
async function cleanupSet(setName) {
const tidsToRemove = [];
await batch.processSortedSet(setName, async (tids) => {
- const topicData = await db.getObjectsFields(tids.map(tid => `topic:${tid}`), ['tid', 'cid']);
+ const topicData = await db.getObjectsFields(tids.map(tid => `topic:${tid}`), ['cid']);
+ topicData.forEach((t, index) => {
+ if (t) {
+ t.tid = tids[index];
+ }
+ });
const batchTids = topicData.filter(
t => t && (!t.cid || !utils.isNumber(t.cid) || t.cid === -1)
).map(t => t.tid);
+
tidsToRemove.push(...batchTids);
progress.incr(tids.length);
}, {