From 3c8ca6360833fe1b31459d6e2e4bb8c4c3166609 Mon Sep 17 00:00:00 2001 From: barisusakli Date: Sun, 7 Sep 2014 12:36:50 -0400 Subject: [PATCH] fixed getCidsByPids --- src/posts.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/posts.js b/src/posts.js index 2a895d329a..9c1285a64b 100644 --- a/src/posts.js +++ b/src/posts.js @@ -408,17 +408,18 @@ var async = require('async'), var tids = posts.map(function(post) { return post.tid; }).filter(function(tid, index, array) { - return array.indexOf(tid) === index; + return tid && array.indexOf(tid) === index; }); topics.getTopicsFields(tids, ['cid'], function(err, topics) { if (err) { return callback(err); } + var map = {}; - topics.forEach(function(topic) { + topics.forEach(function(topic, index) { if (topic) { - map[topic.tid] = topic.cid; + map[tids[index]] = topic.cid; } });