Call to a member function setBlockObject() on a non-object
PermalinkI'm getting below error on specific pages, I am not able to edit page and when I open page, it throws below error.
Page Link :http://www.exrx.net/concrete/People/JTGResume...
Error :
Whoops \ Exception \ ErrorException (E_ERROR) HELP Call to a member function setBlockObject() on a non-object /home/exrx/public_html/concrete/updates/concrete5.7.5.6/concrete/blocks/core_area_layout/controller.php public function getAreaLayoutObject() { if ($this->arLayoutID) { $arLayout = AreaLayout::getByID($this->arLayoutID); $b = $this->getBlockObject(); if (is_object($b)) { $arLayout->setBlockObject($b); }
Did you get anywhere with this? I'm just having the same problem, right after having moved a layout within a page.
Thanks
Another very similar page does not have the problem.
The page with the error has a right sidebar layout and a nav stack in the right sidebar. The left side contains a content block.
I had started reviewing each page of the 6 pages I recently added and when I returned to this one particular page the error was showing under my banner image.
Any new insights on why this happens?
Can I just delete the page and recreate it? Or do I now have a corruption that will pop up later?
It saddens me to say that If this keeps up I will not be using concrete5.7+ for a while.
Regarding your issue: it seems the fix is only merged into the v8 branch, so you'll have to create a controller override in the meanwhile. Add a file called 'controller.php' in /application/blocks/core_area_layout with these contents:
<?php namespace Application\Block\CoreAreaLayout; class Controller extends \Concrete\Block\CoreAreaLayout\Controller { public function getAreaLayoutObject() { if ($this->arLayoutID) { $arLayout = AreaLayout::getByID($this->arLayoutID); $b = $this->getBlockObject(); if (is_object($arLayout) && is_object($b)) { $arLayout->setBlockObject($b); } return $arLayout; } } }
Please let me know if that works for you.
<?php namespace Application\Block\CoreAreaLayout; use Concrete\Core\Area\Layout\Layout as AreaLayout; class Controller extends \Concrete\Block\CoreAreaLayout\Controller { public function getAreaLayoutObject() { if ($this->arLayoutID) { $arLayout = AreaLayout::getByID($this->arLayoutID); $b = $this->getBlockObject(); if (is_object($arLayout) && is_object($b)) { $arLayout->setBlockObject($b); } return $arLayout; } }
I just experienced this issue as well unfortunately. I fixed it by adding the controller as described here as well. However I also had to override the view for core_area_layout by adding a new file in /application/blocks/core_area_layout/view.php with the following content otherwise I then got a new error saying could not call getLayoutContainerHtmlObject on a non object:
Having a fix to stop the errors is one thing, but we need to ensure that this doesn't happen again. Does anyone know how or why this issue occurs and is there any investigation happening into the route of the problem?
Many thanks
David
After hours of trying to get it fixed, I ended up having to delete the whole page and re-created it from scratch. The error somehow wiped-out the blocks contained within the layout areas.
If that doesn't work you I'd temporarily modify the core files, undo the layout in some way, save the page and then revert the core code changes.
I've submitted a PR to fix this in the core, btw:https://github.com/concrete5/concrete5/pull/3942....
Good luck ;)