From 2b9faf46fe6606a9236f9e1ec987f9a22689a2c7 Mon Sep 17 00:00:00 2001 From: Damian Mooyman Date: Mon, 12 Mar 2018 10:31:40 +1300 Subject: [PATCH] BUG Fix InSection failing on non-page controllers Fixes #2119 --- code/Model/SiteTree.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/code/Model/SiteTree.php b/code/Model/SiteTree.php index a63f4e3a..aa4d033b 100755 --- a/code/Model/SiteTree.php +++ b/code/Model/SiteTree.php @@ -759,8 +759,8 @@ class SiteTree extends DataObject implements PermissionProvider, i18nEntityProvi public function InSection($sectionName) { $page = Director::get_current_page(); - while ($page && $page->exists()) { - if ($sectionName == $page->URLSegment) { + while ($page instanceof SiteTree && $page->exists()) { + if ($sectionName === $page->URLSegment) { return true; } $page = $page->Parent();