Skip to content

Node.js based forum software built for the modern web

fix: crash if post doesn't have topic data

Barış Soner Uşaklıeabc6f4763b8
diff --git a/src/posts/category.js b/src/posts/category.js
index c84fe73007..8ca44b4145 100644
--- a/src/posts/category.js
+++ b/src/posts/category.js
@@ -18,7 +18,7 @@ module.exports = function (Posts) {
const tids = _.uniq(postData.map(post => post && post.tid).filter(Boolean));
const topicData = await topics.getTopicsFields(tids, ['cid']);
const tidToTopic = _.zipObject(tids, topicData);
- const cids = postData.map(post => tidToTopic[post.tid].cid);
+ const cids = postData.map(post => tidToTopic[post.tid] && tidToTopic[post.tid].cid);
return cids;
};