magefan / module-blog

Magento 2 Blog Extension is a solution that helps you to create a blog on Magento and manage posts,categories, tags, authors, and comments.
https://magefan.com/magento2-blog-extension
Other
263 stars 135 forks source link

_addBreadcrumbs error on Posts page #13

Closed chris-brabender closed 8 years ago

chris-brabender commented 8 years ago

After a fresh installation of the blog module, I added a new category to get it all to display.

The home page for the blog loads fine, and so does the category page. The hello world post displays in on both pages but clicking in to view the post results in this error:

Recoverable Error: Argument 1 passed to Magefan\Blog\Block\Post\View::_addBreadcrumbs() must be an instance of Magefan\Blog\Model\Post, null given, called in vendor/magefan/module-blog/Block/Post/View.php on line 25 and defined in vendor/magefan/module-blog/Block/Post/View.php on line 41

Changing:

$post = $this->getPost();

To:

$post = $this->_post;

Temporarily fixes the problem for me but it appears the execute() function in the Controller\Post\View action is not being triggered.

chris-brabender commented 8 years ago

It's weird, this happens on our local environment but not on our development servers. I'll keep looking into this myself and see what I can find.

magefan commented 8 years ago

please check if you have the latest version of https://github.com/IhorVansach/Blog-Extension-for-Magento-2/blob/master/Block/Post/View.php

chris-brabender commented 8 years ago

yep these files are identical

magefan commented 8 years ago

Chris, could you please contact to our support via email: support@magefan.com We cannot reproduce this issue on our side.

Sanuch commented 8 years ago

It happens when we use varnish. Magento prepares esi call ProcessLayoutRenderElement.php#L55-L62 for varnish. When we receive request /page_cache/block/esi/blocks/[%22catalog.topnav%22]/handles/[%22default%22,%22blog_post_view%22]/ then your module does not know about current post

magefan commented 8 years ago

Sanuch, please try the last fix

Sanuch commented 8 years ago

Hi @magefan, It works

chris-brabender commented 8 years ago

@magefan thanks for these updates, could you possibly add a new tag so we can pull these down?

magefan commented 8 years ago

@chris-brabender the tag will be available soon