From 27282a2877476885d70fc2512ffb29f4b66d18d6 Mon Sep 17 00:00:00 2001 From: Julian Lam Date: Fri, 27 Feb 2015 12:31:08 -0500 Subject: [PATCH] if no order is specified during a category creation, NodeBB won't crash --- src/categories/create.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/categories/create.js b/src/categories/create.js index af9598866b..a8bfaeb6fc 100644 --- a/src/categories/create.js +++ b/src/categories/create.js @@ -13,7 +13,8 @@ module.exports = function(Categories) { return callback(err); } - var slug = cid + '/' + utils.slugify(data.name); + var slug = cid + '/' + utils.slugify(data.name), + order = data.order || cid; // If no order provided, place it at the end var category = { cid: cid, @@ -27,7 +28,7 @@ module.exports = function(Categories) { topic_count: 0, post_count: 0, disabled: 0, - order: data.order, + order: order, link: '', numRecentReplies: 1, class: 'col-md-3 col-xs-6', @@ -38,7 +39,7 @@ module.exports = function(Categories) { async.series([ async.apply(db.setObject, 'category:' + cid, category), - async.apply(db.sortedSetAdd, 'categories:cid', data.order, cid), + async.apply(db.sortedSetAdd, 'categories:cid', order, cid), async.apply(privileges.categories.give, defaultPrivileges, cid, 'administrators'), async.apply(privileges.categories.give, defaultPrivileges, cid, 'registered-users'), async.apply(privileges.categories.give, ['find', 'read'], cid, 'guests')