From d0779a87bbbdcf1145bd6f01a89c99c3128073bd Mon Sep 17 00:00:00 2001 From: Bianca Nenciu Date: Wed, 26 May 2021 12:40:26 +0300 Subject: [PATCH] FIX: Use max_category_nesting when importing categories (#13105) It allowed for a parent category and a sub-category. --- script/import_scripts/base.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/script/import_scripts/base.rb b/script/import_scripts/base.rb index 7bb49bcde9d..74493357ff1 100644 --- a/script/import_scripts/base.rb +++ b/script/import_scripts/base.rb @@ -430,7 +430,7 @@ class ImportScripts::Base # make sure categories don't go more than 2 levels deep if params[:parent_category_id] top = Category.find_by_id(params[:parent_category_id]) - top = top.parent_category while top && !top.parent_category.nil? + top = top.parent_category while (top&.height_of_ancestors || -1) + 1 >= SiteSetting.max_category_nesting params[:parent_category_id] = top.id if top end