2

After updating from 2.3.5 to 2.4.4-p2 I am getting an error when the frontend loads. This is how it looks, when I load the frontend: https://i.sstatic.net/L1liN.png

The admin works just fine and there are no errors during cimpilation, upgrade or deployment. Any idea how to solve this? The error in the logs is: Error: Call to a member function getCookieSecure() on null in /vendor/magento/module-theme/view/frontend/templates/js/cookie.phtml:21

The code on line 21 is this:

"secure": <?= $block->getSessionConfig()->getCookieSecure() ? 'true' : 'false'; ?>, 

It seems getSessionConfig returns null.

Running on PHP 8.1

Ideas?

1
  • 1
    Some checks you can do: is your custom theme overriding that template? do you have some third party module which could be involved here? try disabling one by one Commented Oct 24, 2022 at 10:00

1 Answer 1

1

Somewhere in your layout you (or an extension) have the following definition:

<block class="Magento\Framework\View\Element\Js\Cookie" name="js_cookies" template="Magento_Theme::js/cookie.phtml"/> 

However, since Magento 2.4.4 (or maybe even sooner) this needs to be updated to

<block class="Magento\Framework\View\Element\Js\Cookie" name="js_cookies" template="Magento_Theme::js/cookie.phtml"> <arguments> <argument name="session_config" xsi:type="object">Magento\Theme\ViewModel\Block\SessionConfig</argument> </arguments> </block> 

otherwise $block->getSessionConfig() in the cookie.phtml template will be null.

1
  • 1
    This is the fix! In my case it was in the child theme I created in app/design Commented Nov 8, 2022 at 21:54

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.