magento2: [2.4.4] Missing Frontend CacheInfo breaks bin/magento

Preconditions and environment

  • Magento 2.4.4
  • Upgrade from 2.3.2
  • Website is a PWA so doesn’t use regular frontend.

Steps to reproduce

composer update --no-dev Run bin/magento.

Expected result

See a list of commands.

Actual result

Warning: Undefined array key "frontend" in ../vendor/magento/framework/App/Cache/Frontend/Pool.php on line 90

Additional information

I have no clue what causes the exact scenario to start happening. But it appears that it’s a minor programming oversight. Where someone assumed that if cacheInfo exists, the frontend cacheInfo also exists which apparently isn’t true.

Fix is changing line 89 from if (null !== $cacheInfo) { to if (null !== $cacheInfo && isset($cacheInfo[FrontendPool::KEY_FRONTEND_CACHE]) {

Release note

No response

Triage and priority

  • Severity: S0 - Affects critical data or functionality and leaves users without workaround.
  • Severity: S1 - Affects critical data or functionality and forces users to employ a workaround.
  • Severity: S2 - Affects non-critical data or functionality and forces users to employ a workaround.
  • Severity: S3 - Affects non-critical data or functionality and does not force users to employ a workaround.
  • Severity: S4 - Affects aesthetics, professional look and feel, “quality” or “usability”.

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 42 (5 by maintainers)

Most upvoted comments

@richardreen, I think @Hexmage has a small error from his suggested fix below, he is missing a closing bracket from the if statement:

Fix is changing line 89 from if (null !== $cacheInfo) { to if (null !== $cacheInfo && isset($cacheInfo[FrontendPool::KEY_FRONTEND_CACHE]) {

Try this instead: if (null !== $cacheInfo && isset($cacheInfo[FrontendPool::KEY_FRONTEND_CACHE])) {

@engcom-Dash We found the cause of the issue, we had the following node in our app/etc/env.php

    'cache' => [
        'graphql' => [
            'id_salt' => '[A SALT HASH]'
        ]
    ] 

Because there is a graphql node it automatically also expects there to be a frontend node, which isn’t always true.

@engcom-Delta This scenario could use some better error handling. Because it’s very unclear that a incorrectly configured FPC is causing the issue.

Okay, dug in a bit.

This probably only happens for shops that were first setup with a version before Magento 2.3.1, and that later got updated to a newer version (needs to be at least 2.4.4).

Before 2.3.1, this change wasn’t included yet, which writes cache > frontend > default/page_cache > id_prefix section to the env.php file at installation time. However, if you later upgrade Magento to a newer version, this still isn’t written to the env.php file automatically. So if we then call the /graphql url/endpoint, Magento will write cache > graphql > id_salt to the env.php file using this code.

And the code mentioned before crashes because it expects a cache > frontend section, which isn’t always guaranteed to be there.


A good fix in my opinion is to run bin/magento setup:config:set without any parameters, it will update the env.php file with all the missing sections automatically (make sure to make a backup of your env.php file so you can compare what got updated). So if you got yourself into the situation this issue describes:

  1. First, execute one of these two:
    • remove the entire cache section from the env.php file
    • or add an empty frontend => [] to the cache section of the env.php file
  2. Now run bin/magento setup:config:set

However, we still need to fix this crash that can happen, will send in a PR shortly with a fix.

@engcom-Dash We have a Magento 2.4.4-p2 and can reproduce the problem just my calling the “/graphql” URL of the store. This adds the “id_salt” value into the env.php and afterwards the frontend returns only http-500. Sounds like a serious problem to me.

I’m confused: this issue was closed with the reason that it’s a duplicate of #35861, but #35861 itself is also closed. So no one is working on this at all?