From: Matthias Schmidt Date: Sun, 27 Nov 2016 13:22:13 +0000 (+0100) Subject: Fix category validation in AbstractCategorizedACPSearchResultProvider X-Git-Tag: 3.0.0_RC_1~120 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=d9f7a5a348e7776c6f659cb2f2c67caa2aa3cb96;p=GitHub%2FWoltLab%2FWCF.git Fix category validation in AbstractCategorizedACPSearchResultProvider --- 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; + } } }