Node.js based forum software built for the modern web
dont crash for undefined categories
Barış Soner Uşaklı29e9310aa5e4
diff --git a/src/categories/index.js b/src/categories/index.jsindex 8f5418c9b8..f7a7a7e8b0 100644--- a/src/categories/index.js+++ b/src/categories/index.js@@ -335,12 +335,14 @@ Categories.flattenCategories = function (allCategories, categoryData) {*/Categories.getTree = function (categories, parentCid) {parentCid = parentCid || 0;- const cids = categories.map(category => category.cid);+ const cids = categories.map(category => category && category.cid);const cidToCategory = {};const parents = {};cids.forEach((cid, index) => {- cidToCategory[cid] = categories[index];- parents[cid] = _.clone(categories[index]);+ if (cid) {+ cidToCategory[cid] = categories[index];+ parents[cid] = _.clone(categories[index]);+ }});const tree = [];