From 5507adadf1406cb5f8ced70ed22e469036de9433 Mon Sep 17 00:00:00 2001 From: Vivek Kannan Date: Tue, 31 Jan 2017 22:20:44 +0530 Subject: [PATCH] Import from LTS blogs now properly adds tags to posts. (#7926) closes #7866 - Importer now uses Javascript's Map instead of the normal object to ensure that tags are properly associated with their corresponding posts. --- core/server/data/import/utils.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/core/server/data/import/utils.js b/core/server/data/import/utils.js index 57a4777187..7b9fa49134 100644 --- a/core/server/data/import/utils.js +++ b/core/server/data/import/utils.js @@ -108,17 +108,17 @@ utils = { preProcessPostTags: function preProcessPostTags(tableData) { var postTags, - postsWithTags = {}; + postsWithTags = new Map(); postTags = tableData.posts_tags; _.each(postTags, function (postTag) { - if (!postsWithTags.hasOwnProperty(postTag.post_id)) { - postsWithTags[postTag.post_id] = []; + if (!postsWithTags.get(postTag.post_id)) { + postsWithTags.set(postTag.post_id, []); } - postsWithTags[postTag.post_id].push(postTag.tag_id); + postsWithTags.get(postTag.post_id).push(postTag.tag_id); }); - _.each(postsWithTags, function (tagIds, postId) { + postsWithTags.forEach(function (tagIds, postId) { var post, tags; post = _.find(tableData.posts, function (post) { return post.id === postId;