mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-08 06:55:46 +01:00
closes #6567 prevent crash if category is undefined
This commit is contained in:
@@ -307,12 +307,9 @@ Categories.flattenCategories = function (allCategories, categoryData) {
|
|||||||
*/
|
*/
|
||||||
Categories.getTree = function (categories, parentCid) {
|
Categories.getTree = function (categories, parentCid) {
|
||||||
var tree = [];
|
var tree = [];
|
||||||
var i = 0;
|
|
||||||
var len = categories.length;
|
|
||||||
var category;
|
|
||||||
|
|
||||||
for (i; i < len; i += 1) {
|
categories.forEach(function (category) {
|
||||||
category = categories[i];
|
if (category) {
|
||||||
if (!category.hasOwnProperty('parentCid') || category.parentCid === null) {
|
if (!category.hasOwnProperty('parentCid') || category.parentCid === null) {
|
||||||
category.parentCid = 0;
|
category.parentCid = 0;
|
||||||
}
|
}
|
||||||
@@ -322,6 +319,7 @@ Categories.getTree = function (categories, parentCid) {
|
|||||||
category.children = Categories.getTree(categories, category.cid);
|
category.children = Categories.getTree(categories, category.cid);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
|
||||||
return tree;
|
return tree;
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user