diff --git a/src/topics/tags.js b/src/topics/tags.js index 48ef3dba41..527913557a 100644 --- a/src/topics/tags.js +++ b/src/topics/tags.js @@ -327,12 +327,13 @@ module.exports = function(Topics) { return plugins.fireHook('filter:topic.getRelatedTopics', {topic: topicData, uid: uid}, callback); } - var maximumTopics = parseInt(meta.config.maximumRelatedTopics, 10) || 5; - - if (!topicData.tags.length || maximumTopics === 0) { + var maximumTopics = parseInt(meta.config.maximumRelatedTopics, 10); + if (maximumTopics === 0 || !topicData.tags.length) { return callback(null, []); } + maximumTopics = maximumTopics || 5; + async.waterfall([ function (next) { async.map(topicData.tags, function (tag, next) {