From f454f481f25e25406e7b0236d89f19a65a4ea58c Mon Sep 17 00:00:00 2001 From: Ingo Schommer Date: Tue, 28 Aug 2012 00:28:58 +0200 Subject: [PATCH] BUG Session namespace sharing for CMS controllers Ideally we could do this without session, but pragmatically we still need it, because of the inflexible routing system, and because of performance considerations. Example: The tree is lazy loaded via a generic URL (admin/pages/treeview). While we could add ?ID= to make the view (more or less) stateless, it would trigger a full tree reload on every tree navigation action. Instead, we assume that all "reachable" nodes are already cached, and simply mark a different one as current. For this to work, we need shared session state between CMS controllers. See http://open.silverstripe.org/ticket/7815 for detail. --- code/controllers/CMSPageEditController.php | 2 ++ code/controllers/CMSPageHistoryController.php | 1 + code/controllers/CMSPageSettingsController.php | 1 + code/controllers/CMSPagesController.php | 9 +-------- 4 files changed, 5 insertions(+), 8 deletions(-) diff --git a/code/controllers/CMSPageEditController.php b/code/controllers/CMSPageEditController.php index 5027f6d9..05df5f2d 100644 --- a/code/controllers/CMSPageEditController.php +++ b/code/controllers/CMSPageEditController.php @@ -9,4 +9,6 @@ class CMSPageEditController extends CMSMain { static $url_rule = '/$Action/$ID/$OtherID'; static $url_priority = 41; static $required_permission_codes = 'CMS_ACCESS_CMSMain'; + static $session_namespace = 'CMSMain'; + } diff --git a/code/controllers/CMSPageHistoryController.php b/code/controllers/CMSPageHistoryController.php index 3a076b65..43251753 100644 --- a/code/controllers/CMSPageHistoryController.php +++ b/code/controllers/CMSPageHistoryController.php @@ -11,6 +11,7 @@ class CMSPageHistoryController extends CMSMain { static $url_priority = 42; static $menu_title = 'History'; static $required_permission_codes = 'CMS_ACCESS_CMSMain'; + static $session_namespace = 'CMSMain'; static $allowed_actions = array( 'VersionsForm', diff --git a/code/controllers/CMSPageSettingsController.php b/code/controllers/CMSPageSettingsController.php index d8ff7d4d..592cad29 100644 --- a/code/controllers/CMSPageSettingsController.php +++ b/code/controllers/CMSPageSettingsController.php @@ -9,6 +9,7 @@ class CMSPageSettingsController extends CMSMain { static $url_rule = '/$Action/$ID/$OtherID'; static $url_priority = 42; static $required_permission_codes = 'CMS_ACCESS_CMSMain'; + static $session_namespace = 'CMSMain'; function getEditForm($id = null, $fields = null) { $record = $this->getRecord($id ? $id : $this->currentPageID()); diff --git a/code/controllers/CMSPagesController.php b/code/controllers/CMSPagesController.php index 5f401d7a..56aa2687 100644 --- a/code/controllers/CMSPagesController.php +++ b/code/controllers/CMSPagesController.php @@ -10,6 +10,7 @@ class CMSPagesController extends CMSMain { static $url_priority = 40; static $menu_title = 'Pages'; static $required_permission_codes = 'CMS_ACCESS_CMSMain'; + static $session_namespace = 'CMSMain'; function LinkPreview() { return false; @@ -22,14 +23,6 @@ class CMSPagesController extends CMSMain { return $this->request->getVar('view'); } - /** - * Doesn't deal with a single record, and we need - * to avoid session state from previous record edits leaking in here. - */ - public function currentPageID() { - return false; - } - public function isCurrentPage(DataObject $record) { return false; }