closes #6567 prevent crash if category is undefined

This commit is contained in:
Barış Soner Uşaklı
2018-06-10 10:28:17 -04:00
parent 67c0f02243
commit d656c65c9a

View File

@@ -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;
}; };