Skip to content
This repository
Browse code

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=<currentpage> 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.
  • Loading branch information...
commit f454f481f25e25406e7b0236d89f19a65a4ea58c 1 parent 651cb03
Ingo Schommer authored August 28, 2012
2  code/controllers/CMSPageEditController.php
@@ -9,4 +9,6 @@ class CMSPageEditController extends CMSMain {
9 9
 	static $url_rule = '/$Action/$ID/$OtherID';
10 10
 	static $url_priority = 41;
11 11
 	static $required_permission_codes = 'CMS_ACCESS_CMSMain';
  12
+	static $session_namespace = 'CMSMain';
  13
+
12 14
 }
1  code/controllers/CMSPageHistoryController.php
@@ -11,6 +11,7 @@ class CMSPageHistoryController extends CMSMain {
11 11
 	static $url_priority = 42;
12 12
 	static $menu_title = 'History';
13 13
 	static $required_permission_codes = 'CMS_ACCESS_CMSMain';
  14
+	static $session_namespace = 'CMSMain';
14 15
 	
15 16
 	static $allowed_actions = array(
16 17
 		'VersionsForm',
1  code/controllers/CMSPageSettingsController.php
@@ -9,6 +9,7 @@ class CMSPageSettingsController extends CMSMain {
9 9
 	static $url_rule = '/$Action/$ID/$OtherID';
10 10
 	static $url_priority = 42;
11 11
 	static $required_permission_codes = 'CMS_ACCESS_CMSMain';
  12
+	static $session_namespace = 'CMSMain';
12 13
 		
13 14
 	function getEditForm($id = null, $fields = null) {
14 15
 		$record = $this->getRecord($id ? $id : $this->currentPageID());
9  code/controllers/CMSPagesController.php
@@ -10,6 +10,7 @@ class CMSPagesController extends CMSMain {
10 10
 	static $url_priority = 40;
11 11
 	static $menu_title = 'Pages';	
12 12
 	static $required_permission_codes = 'CMS_ACCESS_CMSMain';
  13
+	static $session_namespace = 'CMSMain';
13 14
 
14 15
 	function LinkPreview() {
15 16
 		return false;
@@ -22,14 +23,6 @@ public function ViewState() {
22 23
 		return $this->request->getVar('view');
23 24
 	}
24 25
 
25  
-	/**
26  
-	 * Doesn't deal with a single record, and we need
27  
-	 * to avoid session state from previous record edits leaking in here.
28  
-	 */
29  
-	public function currentPageID() {
30  
-		return false;
31  
-	}
32  
-
33 26
 	public function isCurrentPage(DataObject $record) {
34 27
 		return false;
35 28
 	}

0 notes on commit f454f48

Please sign in to comment.
Something went wrong with that request. Please try again.