From d9f7a5a348e7776c6f659cb2f2c67caa2aa3cb96 Mon Sep 17 00:00:00 2001 From: Matthias Schmidt Date: Sun, 27 Nov 2016 14:22:13 +0100 Subject: [PATCH] Fix category validation in AbstractCategorizedACPSearchResultProvider --- ...ractCategorizedACPSearchResultProvider.class.php | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/wcfsetup/install/files/lib/system/search/acp/AbstractCategorizedACPSearchResultProvider.class.php b/wcfsetup/install/files/lib/system/search/acp/AbstractCategorizedACPSearchResultProvider.class.php index b906b13d85..b47c258e62 100644 --- a/wcfsetup/install/files/lib/system/search/acp/AbstractCategorizedACPSearchResultProvider.class.php +++ b/wcfsetup/install/files/lib/system/search/acp/AbstractCategorizedACPSearchResultProvider.class.php @@ -109,9 +109,16 @@ abstract class AbstractCategorizedACPSearchResultProvider extends AbstractACPSea // create level 2 categories $topCategories = []; - foreach ($this->categories as $category) { - if ($category->parentCategoryName && in_array($category->parentCategoryName, $this->topCategories)) { - $topCategories[] = $category->categoryName; + foreach ($this->categories as $key => $category) { + if ($category->parentCategoryName) { + // check if parent category exists, thus if it is valid; if is does not exist, then all + // child categories are also invalid + if (!isset($this->categories[$category->parentCategoryName])) { + unset($this->categories[$key]); + } + else if (in_array($category->parentCategoryName, $this->topCategories)) { + $topCategories[] = $category->categoryName; + } } } -- 2.20.1