9

Whenver I turn on FPC(Full Page Cache) feature in my Magento CE 2.0.2 site (doesn't matter if default theme or custom theme is running.) and when I open the Homepage of this site, then it gives "Internal Server Error 500" in the Firefox console, and the page is blank.

What could be the possible issue ?

3
  • Try enabling developer mode to see what the error is (also look in your web server's error log). Mar 7, 2016 at 18:32
  • Have you found a solution? we have the same problem on 2.0.6
    – Max
    Aug 22, 2016 at 11:40
  • Same problem for us on 2.1.1, PHP 5.6 FPM, Nginx. Enabling developer mode doesn't provide any additional information. The PHP error we're getting is PHP Fatal error: Call to a member function getIdentities() on null in /vendor/magento/module-catalog/Block/Product/View.php on line 373 The problem is in the function getIdentities() on the line: $identities = $this->getProduct()->getIdentities(); $this->getProduct() is null when Full Page Cache is enabled. Sep 15, 2016 at 14:36

2 Answers 2

14

We had the same issue after enabling FPC. The following error would occur:

Fatal error: Uncaught Error: Call to a member function getIdentities() on null in /vendor/magento/module-catalog/Block/Category/View.php:177 

Not the most helpful error message but after some digging we found that this was being triggered by using the block type Magento\Catalog\Block\Category\View on our homepage - presumably because there is no category initialised at that point.

This was a coding error by one of our developers as this particular block did not need that type and was fine with just Magento\Framework\View\Element\Template which is the Magento 2 equivalent of core/template.

2

rewrite the function like this to handle the null values:


public function getIdentities()
    {
        $identities = [];

        if (is_array($this->getItems()) || is_object($this->getItems()))
        {
            foreach ($this->getItems() as $item)
            {
                $identities = array_merge($identities, $item->getIdentities());
            }
        }
        return $identities;

}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.