6

All of a sudden a cache tag was added to my env.php which made made my Magento 2.4.4 crash.

enter image description here

I cannot run cache flush or anything without getting the following error: Notice: Undefined index: frontend in

/var/www/magento2/vendor/magento/framework/App/Cache/Frontend/Pool.php on line 90

When I remove the cache-tag, everything works are normal again.

How could this tag appear out of nowhere?? Is this a hack?

EDIT: Everything was not normal. Checkout did not work at all. Got loads of errors in the console. Had to rollback the whole site to yesterdays backup. Very concerning.

1
  • We are also getting this issue, have you found any solution? Aug 2, 2022 at 10:38

9 Answers 9

5

If you don't have a cache entry in your env.php array, Magento will break when the GraphQL module decides to add a salt entry within the cache key. The moment ['cache'] exists, Magento also expects ['cache']['frontend'] to exist too. See this GitHub issue for more info: https://github.com/magento/magento2/issues/35861

Removing the whole cache entry where the GraphQL was generated and stored will fix things, but then the issue will come back when Magento decides to generate the salt again. For a longer term fix, add an empty value for ['cache']['frontend'] either next to the generated GraphQL salt, or next to it, not important which:

'cache' => [
    'frontend' => [],
],

or

'cache' => [
    'frontend' => [],
    'graphql' => [
        'id_salt' => 'ABC123'
    ]
],

It's fair to assume that you're here because you didn't already have a value against ['cache']['frontend'] but if you did, you've hit a separate issue.

1
  • This was interesting, I will try it out.
    – maxo
    Jan 23 at 9:10
3

vendor/magento/framework/App/Cache/Frontend/Pool.php line 89 changed from if (null !== $cacheInfo) { to if (null !== $cacheInfo && isset($cacheInfo[FrontendPool::KEY_FRONTEND_CACHE])) {

That fixed my issue.

2

This problem is running since 2.4.4 confirmed. When GraphQL endpoint gets called and there is no id_salt available, magento will create an entry itself.

Problem with the above; it does that even when you do not have cache keys defined. This will result in an error because magento will search for the frontend cache settings when the 'cache' key is defined in env.php, but only the graphql key exists. A solution we did was to always ensure that cache keys are defined in env.php:

'cache' => [
    'frontend' => [
        'default' => [
            'backend' => 'Magento\\Framework\\Cache\\Backend\\Redis',
            'backend_options' => [
                'server' => '127.0.0.1',
                'database' => '0',
                'port' => '6379'
            ],
        ],
        'page_cache' => [
            'backend' => 'Magento\\Framework\\Cache\\Backend\\Redis',
            'backend_options' => [
                'server' => '127.0.0.1',
                'port' => '6379',
                'database' => '1',
                'compress_data' => '0'
            ]
        ]
    ]
]

Now, you can leave the graphql cache settings without the site completely breaking.

0

...also having the exact same issue. Are you playing with Avada? It seems to happen when we add a product grid to an Avada campaign, but we're not sure.

2
  • No, not using Avada. Checkout didn't work anymore even after this change, so I had to roll back to yesterdays backup. Very strange..
    – maxo
    Jul 19, 2022 at 14:17
  • That is strange - we're looking into it so if we find something we'll let you know.
    – Ben
    Jul 19, 2022 at 16:54
0

It showed up for us too. Removing that new cache section from ENV restored function. We aren't using Avada. It showed up on a site where we had disabled Redis, for what it's worth.

1
  • But does checkout work for you after this? I had to restore my hole site from backup because checkout didn't work.
    – maxo
    Jul 21, 2022 at 19:07
0

This just happened today to both of the two Magento 2 sites that I host, thanks a bunch for noting the cache tag!

In both of my installations the env.php was 'last modified' today and removing the cache tag restored everything back to normal. We don't have Avada in either one of the installations, but both installations have several Amasty extensions and Magezon Page Builder, plus they both have Olegnax Athlete2 Theme with most of the extensions enabled.

I haven't checked the checkout function yet, but we need to check that out.

EDIT: Everything seems to be normal now, including the checkout. (mind you, the other site had a "application run" error at order success page already before this and it's still there, but I'm on it.)

0

We've had this on several of our Magento 2.4.4 websites (No earlier versions seen to have the issue). The issue seemingly occurs at random and is fixed temporarily by removing the cache graphql section added to the env.php file.

Be aware that in our case the issue has re-occurred on several occasions on the same website. Removing the graphql section fixes it in each case.

Update: Further investigation has revealed the location in the magento codebase which is setting the SALT env information. In vendor/magento/module-graph-ql-cache/Model/CacheId/CacheIdCalculator.php within the method getSalt(), you can see that if a salt is not detected that it sets a new salt value.

We've also identified that we can trigger the issue by accessing the websites graphql url at https://yourmagento2-server/graphql

1
-1

I had the same issue 2 weeks ago on 2 sites and edited the ENV to comment out the cache, today it's down again. One site shows in the exception log:

The current customer isn't authorized. {"exception":"[object] (GraphQL\Error\Error(code: 0): The current customer isn't authorized. at /var/www/vhosts/mysite.com/htdocs/vendor/webonyx/graphql-php/src/Error/Error.php:174, Magento\Framework\GraphQl\Exception\GraphQlAuthorizationException(code: 0): The current customer isn't authorized. at /var/www/vhosts/mysite.com/htdocs/vendor/magento/module-customer-downloadable-graph-ql/Model/Resolver/CustomerDownloadableProducts.php:59)"} []

for sure the cache entry in the ENV is new.

-1

I ran this command to disable GraphQL on my client's site. Seems to be working for over a week now:

php bin/magento module:disable Magento_AuthorizenetGraphQl Magento_BraintreeGraphQl Magento_BundleGraphQl Magento_CatalogCmsGraphQl Magento_CatalogCustomerGraphQl Magento_CatalogUrlRewriteGraphQl Magento_CheckoutAgreementsGraphQl Magento_CmsUrlRewriteGraphQl Magento_ConfigurableProductGraphQl Magento_CustomerDownloadableGraphQl Magento_DirectoryGraphQl Magento_GraphQlCache Magento_GroupedProductGraphQl Magento_PaypalGraphQl Magento_RelatedProductGraphQl Magento_SalesGraphQl Magento_SendFriendGraphQl Magento_StoreGraphQl Magento_SwatchesGraphQl Magento_TaxGraphQl Magento_ThemeGraphQl Magento_VaultGraphQl Magento_WeeeGraphQl Magento_WishlistGraphQl

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.