Skip to content

Node.js based forum software built for the modern web

closes #3821

barisusaklifb7f10d63d35
diff --git a/src/topics/fork.js b/src/topics/fork.js
index aefb2a88cd..fa4633fdd6 100644
--- a/src/topics/fork.js
+++ b/src/topics/fork.js
@@ -103,6 +103,9 @@ module.exports = function(Topics) {
},
function(next) {
async.parallel([
+ function(next) {
+ updateCategoryPostCount(postData.tid, tid, next);
+ },
function(next) {
Topics.decreasePostCount(postData.tid, next);
},
@@ -132,6 +135,24 @@ module.exports = function(Topics) {
});
};
+ function updateCategoryPostCount(oldTid, tid, callback) {
+ Topics.getTopicsFields([oldTid, tid], ['cid'], function(err, topicData) {
+ if (err) {
+ return callback(err);
+ }
+ if (!topicData[0].cid || !topicData[1].cid) {
+ return callback();
+ }
+ if (parseInt(topicData[0].cid, 10) === parseInt(topicData[1].cid, 10)) {
+ return callback();
+ }
+ async.parallel([
+ async.apply(db.incrObjectFieldBy, 'category:' + topicData[0].cid, 'post_count', -1),
+ async.apply(db.incrObjectFieldBy, 'category:' + topicData[1].cid, 'post_count', 1)
+ ], callback);
+ });
+ }
+
function updateRecentTopic(tid, callback) {
async.waterfall([
function(next) {