7

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 ?

  • Try enabling developer mode to see what the error is (also look in your web server's error log). – Steve Johnson Mar 7 '16 at 18:32
  • Have you found a solution? we have the same problem on 2.0.6 – Max Aug 22 '16 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. – Matt Mombrea Sep 15 '16 at 14:36
10

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, privacy policy and cookie policy

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