BUG Fix InSection failing on non-page controllers

Fixes #2119
This commit is contained in:
Damian Mooyman 2018-03-12 10:31:40 +13:00
parent 3eae840679
commit 2b9faf46fe
No known key found for this signature in database
GPG Key ID: 78B823A10DE27D1A

View File

@ -759,8 +759,8 @@ class SiteTree extends DataObject implements PermissionProvider, i18nEntityProvi
public function InSection($sectionName) public function InSection($sectionName)
{ {
$page = Director::get_current_page(); $page = Director::get_current_page();
while ($page && $page->exists()) { while ($page instanceof SiteTree && $page->exists()) {
if ($sectionName == $page->URLSegment) { if ($sectionName === $page->URLSegment) {
return true; return true;
} }
$page = $page->Parent(); $page = $page->Parent();