mirror of
https://github.com/silverstripe/silverstripe-cms
synced 2024-10-22 08:05:56 +02:00
BUGFIX Passing current request on to LeftAndMain singletons in CMSMenu::get_viewable_menu_items() to avoid state errors (e.g. when decorators check request data, see "subsites" module)
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/cms/trunk@115109 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
b22a37da6c
commit
4d127c5976
@ -206,7 +206,13 @@ class CMSMenu extends Object implements IteratorAggregate, i18nEntityProvider
|
|||||||
if($allMenuItems) foreach($allMenuItems as $code => $menuItem) {
|
if($allMenuItems) foreach($allMenuItems as $code => $menuItem) {
|
||||||
// exclude all items which have a controller to perform permission
|
// exclude all items which have a controller to perform permission
|
||||||
// checks on
|
// checks on
|
||||||
if($menuItem->controller && !singleton($menuItem->controller)->canView($member)) continue;
|
if($menuItem->controller) {
|
||||||
|
$controllerObj = singleton($menuItem->controller);
|
||||||
|
// Necessary for canView() to have request data available,
|
||||||
|
// e.g. to check permissions against LeftAndMain->currentPage()
|
||||||
|
$controllerObj->setRequest(Controller::curr()->getRequest());
|
||||||
|
if(!$controllerObj->canView($member)) continue;
|
||||||
|
}
|
||||||
|
|
||||||
$viewableMenuItems[$code] = $menuItem;
|
$viewableMenuItems[$code] = $menuItem;
|
||||||
}
|
}
|
||||||
|
@ -109,7 +109,8 @@ class LeftAndMain extends Controller {
|
|||||||
*/
|
*/
|
||||||
function init() {
|
function init() {
|
||||||
parent::init();
|
parent::init();
|
||||||
|
var_dump('init');
|
||||||
|
var_dump($this->request);
|
||||||
SSViewer::setOption('rewriteHashlinks', false);
|
SSViewer::setOption('rewriteHashlinks', false);
|
||||||
|
|
||||||
// set language
|
// set language
|
||||||
@ -1002,6 +1003,7 @@ class LeftAndMain extends Controller {
|
|||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
public function currentPageID() {
|
public function currentPageID() {
|
||||||
|
if(!$this->request) SS_Backtrace::backtrace();
|
||||||
if($this->request->getVar('ID')) {
|
if($this->request->getVar('ID')) {
|
||||||
return $this->request->getVar('ID');
|
return $this->request->getVar('ID');
|
||||||
} elseif ($this->request->param('ID') && is_numeric($this->request->param('ID'))) {
|
} elseif ($this->request->param('ID') && is_numeric($this->request->param('ID'))) {
|
||||||
|
Loading…
Reference in New Issue
Block a user