From 9929284a9bed34e588b9d9c3598aff13de6421eb Mon Sep 17 00:00:00 2001 From: Robbie Averill Date: Mon, 4 Sep 2017 16:56:42 +1200 Subject: [PATCH] FIX Replace static session getter for the current page ID --- code/Model/Recipient/EmailRecipient.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/code/Model/Recipient/EmailRecipient.php b/code/Model/Recipient/EmailRecipient.php index 21365dd..9e5b42b 100644 --- a/code/Model/Recipient/EmailRecipient.php +++ b/code/Model/Recipient/EmailRecipient.php @@ -2,12 +2,12 @@ namespace SilverStripe\UserForms\Model\Recipient; +use SilverStripe\Admin\LeftAndMain; use SilverStripe\Assets\FileFinder; use SilverStripe\CMS\Controllers\CMSMain; use SilverStripe\CMS\Controllers\CMSPageEditController; use SilverStripe\Control\Controller; use SilverStripe\Control\Email\Email; -use SilverStripe\Control\Session; use SilverStripe\Core\Manifest\ModuleLoader; use SilverStripe\Forms\CheckboxField; use SilverStripe\Forms\DropdownField; @@ -118,9 +118,12 @@ class EmailRecipient extends DataObject */ protected function getFormParent() { + // LeftAndMain::sessionNamespace is protected. @todo replace this with a non-deprecated equivalent. + $sessionNamespace = $this->config()->get('session_namespace') ?: LeftAndMain::class; + $formID = $this->FormID ? $this->FormID - : Session::get('CMSMain.currentPage'); + : Controller::curr()->getRequest()->getSession()->get($sessionNamespace . '.currentPage'); return UserDefinedForm::get()->byID($formID); }