Skip to content

Node.js based forum software built for the modern web

if source has no parentCid assume 0

Barış Soner Uşaklı5ee4529a8e89
diff --git a/src/categories/create.js b/src/categories/create.js
index 9c20522e85..cd8f7bdfe7 100644
--- a/src/categories/create.js
+++ b/src/categories/create.js
@@ -149,12 +149,13 @@ module.exports = function (Categories) {
var tasks = [];
- if (copyParent && utils.isNumber(destination.parentCid)) {
- tasks.push(async.apply(db.sortedSetRemove, 'cid:' + destination.parentCid + ':children', toCid));
+ const oldParent = parseInt(destination.parentCid, 10) || 0;
+ const newParent = parseInt(results.source.parentCid, 10) || 0;
+ if (copyParent) {
+ tasks.push(async.apply(db.sortedSetRemove, 'cid:' + oldParent + ':children', toCid));
}
-
- if (copyParent && utils.isNumber(results.source.parentCid)) {
- tasks.push(async.apply(db.sortedSetAdd, 'cid:' + results.source.parentCid + ':children', results.source.order, toCid));
+ if (copyParent) {
+ tasks.push(async.apply(db.sortedSetAdd, 'cid:' + newParent + ':children', results.source.order, toCid));
}
destination.description = results.source.description;