Call to a member function setBlockObject() on a non-object
Permalink
Hi,
I'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 :
I'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); }
Thanks.
Hi,
Did you get anywhere with this? I'm just having the same problem, right after having moved a layout within a page.
Thanks
Did you get anywhere with this? I'm just having the same problem, right after having moved a layout within a page.
Thanks
I also had the same problem while working on a fresh install of 5.7.5.9. One minute all is going well and the error comes up just under my header image: "An unexpected error occurred. Call to a member function setBlockObject() on a non-object".
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.
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.
I don't mind if you use c5 or not. If you want to use WordPress, no problemo.
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:
Please let me know if that works for you.
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.
Great - that seems to be working, thanks! Though you need a use statement in there. Full code:
<?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; } }
Viewing 15 lines of 16 lines. View entire code block.
Ah yeah, I didn't test it. Glad to hear you got it working.
Hi All
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
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
5.7.5.13 fixed it for me
I have seen this error today when saving block edits on v8., v8.0 and v8.0.3. It happens randomly and a subsequent save is usually successful. So perhaps the fix is not 100% reliable.
Just happened to me in 8.1.
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.
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.
I'm also getting this error in 8.1 ... I'm trying to figure out if its my block code or if something else is going on.
Did you figure this out? I am having the same issue. All a sudden out of nowhere it started happening.
Did you figure this out? I am having the same issue. All a sudden out of nowhere it started happening.
@duurainen did you try bvcreative fix?
I tried and it had no effect. I was not able to fix the problem and was forced to recreate the page.
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 ;)