From 2954224a1de17d0cc295a1afd4503500531dd0f8 Mon Sep 17 00:00:00 2001 From: Ed Chipman Date: Tue, 1 Feb 2022 16:32:07 -0400 Subject: [PATCH] FIX: Fixed issue where a crash could occur when an error page is generated by the CMS (#59) * FIX: Fixed issue where a crash could occur when an error page is generated by the CMS * Added doc block --- src/ErrorPageController.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/ErrorPageController.php b/src/ErrorPageController.php index 628c4b3..b4456cf 100644 --- a/src/ErrorPageController.php +++ b/src/ErrorPageController.php @@ -4,12 +4,24 @@ use PageController; use SilverStripe\Control\HTTPRequest; use SilverStripe\Control\HTTPResponse; +use SilverStripe\View\SSViewer; /** * Controller for ErrorPages. */ class ErrorPageController extends PageController { + /** + * Explicitly set themes to the themes config value in case the theme was previously set to something else + * One example of this is when serving 404 error pages under the admin path e.g. admin/non-existent + * where LeftAndMain::init() will have previously set themes to the admin_themes config + */ + protected function init() + { + SSViewer::set_themes(SSViewer::config()->themes); + parent::init(); + } + /** * Overload the provided {@link Controller::handleRequest()} to append the * correct status code post request since otherwise permission related error