From 335169f2b15647caa3b91f84b274988339c711c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Soner=20U=C5=9Fakl=C4=B1?= Date: Fri, 31 Jul 2020 18:20:24 -0400 Subject: [PATCH] fix: don't process invalid topics, fallback to 0 score --- src/upgrades/1.14.1/readd_deleted_recent_topics.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/upgrades/1.14.1/readd_deleted_recent_topics.js b/src/upgrades/1.14.1/readd_deleted_recent_topics.js index e48afc6291..d2a413a514 100644 --- a/src/upgrades/1.14.1/readd_deleted_recent_topics.js +++ b/src/upgrades/1.14.1/readd_deleted_recent_topics.js @@ -16,6 +16,9 @@ module.exports = { tids.map(tid => 'topic:' + tid), ['tid', 'lastposttime', 'viewcount', 'postcount', 'upvotes', 'downvotes'] ); + if (!topicData.tid) { + return; + } topicData.forEach((t) => { if (t.hasOwnProperty('upvotes') && t.hasOwnProperty('downvotes')) { t.votes = parseInt(t.upvotes, 10) - parseInt(t.downvotes, 10); @@ -23,7 +26,7 @@ module.exports = { }); await db.sortedSetAdd('topics:recent', - topicData.map(t => t.lastposttime), + topicData.map(t => t.lastposttime || 0), topicData.map(t => t.tid) );