mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
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:
parent
9c80282dfd
commit
9f78d4aa5e
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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");
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user