Fixed bugs in Session implementation of nested controllers

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@40451 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Sam Minnee 2007-08-17 23:11:43 +00:00
parent 9c80282dfd
commit 9f78d4aa5e
3 changed files with 15 additions and 4 deletions

View File

@ -352,7 +352,10 @@ class Controller extends ViewableData {
function pushCurrent() {
array_unshift(self::$controller_stack, $this);
// Create a new session object
if(!$this->session) $this->session = new Session(null);
if(!$this->session) {
if(self::$controller_stack[1]) $this->session = self::$controller_stack[1]->getSession();
else $this->session = new Session(null);
}
}
/**

View File

@ -8,9 +8,14 @@
class ModelAsController extends Controller implements NestedController {
public function run($requestParams) {
$this->pushCurrent();
$this->init();
$nested = $this->getNestedController();
return $nested->run($requestParams);
$result = $nested->run($requestParams);
$this->popCurrent();
return $result;
}
public function init() {
@ -19,7 +24,6 @@ class ModelAsController extends Controller implements NestedController {
public function getNestedController() {
if($this->urlParams['URLSegment']) {
$child = DataObject::get_one("SiteTree", "URLSegment = '" . addslashes($this->urlParams['URLSegment']) . "'");
if(!$child) {
header("HTTP/1.0 404 Not Found");

View File

@ -9,13 +9,17 @@ class RootURLController extends Controller {
public function run($requestParams) {
self::$is_at_root = true;
$this->pushCurrent();
$controller = new ModelAsController();
$controller->setUrlParams(array(
'URLSegment' => self::get_homepage_urlsegment(),
'Action' => '',
));
return $controller->run($requestParams);
$result = $controller->run($requestParams);
$this->popCurrent();
return $result;
}
/**