Cleared Cache on site and now getting an error?

Permalink
I just cleared the cache on my site and now some pages are pulling up this error "
Fatal error: Call to a member function getBlockTypeHandle() on a non-object in C:\inetpub\vhosts\insyntrix.net\httpdocs\Octagon\concrete\libraries\block_view_template.php on line 41"

Does anyone have any ideas as to what happened or what I can do, I did not edit the file that it's talking about. This site is to go live tonight, so I need to fix this problem ASAP, any help would be much appreciated.

 
Job replied on at Permalink Reply
Job
czrlopez

This is what you get when you have an error in one of your Blocks and they're pesky buggers to debug.

Try create a page without any custom blocks you may have created. Add any blocks in one by one and determine which is causing the error.

After you've done that, it might be an idea to post your block code so that we can help debug it.

I've found I get these when I do things like ::getByID or ::getbyHandle without checking if it loads correctly.

EG. For a Page ...

$cObj = Page::getById(125);
if(is_object($cObj)) {
  // what you would have normally done
}


If you post your offending code I'd be happy to look through it.

Don't forget to mark my reply as the answer if it helps you!

Job.
czrlopez replied on at Permalink Reply
Job,
Thanks for your help, but I did not create any custom blocks, I was just using the default C5 blocks and these pages were mainly using the content block, nothing fancy. I will look for the code its talking about in line 41 and I will post it and see if it makes sense.
Job replied on at Permalink Reply
Job
czrlopez

It's nothing wrong with the code thats being mentioned in the error, thats in the core and definitaly works.

Its the file that is called when rendering a block's view. Something custom is causing this error.

Is it on every page, or just some? Did you create your own theme? Are there any hard-coded blocks in there?
czrlopez replied on at Permalink Reply
Job,
Its not on every page just some, about 4 pages and I did create the theme and the only thing that I can think of that was hard coded was the search block, but thats in the header.php and obviously its on all pages, so if it was this shouldn't it giving the error for all pages?

Here is the block of code it mentions in the error
public function __construct($obj) {
(this is line 41)$this->btHandle = $obj->getBlockTypeHandle();
      $this->obj = $obj;
      if ($obj instanceof Block) {
         $this->bFilename = $obj->getBlockFilename();
      }
      $this->computeView();
   }
Job replied on at Permalink Reply
Job
czrlopez

As I said, its nothing to do with the code in the core.

You need to have a think about what's different on those 4 pages to the rest. Whatever is different on those 4 pages is why they're the only ones getting the error, then when we know what it is we can try to fix it.

Get back to me.

Job.
czrlopez replied on at Permalink Reply
Job,
Alright thanks I will take a look around and will let you know what I come up with.