Skip to content

[2.4.4] Missing Frontend CacheInfo breaks bin/magento #35812

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
1 of 5 tasks
Hexmage opened this issue Jul 25, 2022 · 42 comments · Fixed by #38119
Closed
1 of 5 tasks

[2.4.4] Missing Frontend CacheInfo breaks bin/magento #35812

Hexmage opened this issue Jul 25, 2022 · 42 comments · Fixed by #38119
Assignees
Labels
Issue: needs update Additional information is require, waiting for response Reported on 2.4.4 Indicates original Magento version for the Issue report.

Comments

@Hexmage
Copy link

Hexmage commented Jul 25, 2022

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”.
@m2-assistant
Copy link

m2-assistant bot commented Jul 25, 2022

Hi @Hexmage. Thank you for your report.
To speed up processing of this issue, make sure that you provided the following information:

  • Summary of the issue
  • Information on your environment
  • Steps to reproduce
  • Expected and actual results

Make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, Add a comment to the issue:

@magento give me 2.4-develop instance - upcoming 2.4.x release

For more details, review the Magento Contributor Assistant documentation.

Add a comment to assign the issue: @magento I am working on this

To learn more about issue processing workflow, refer to the Code Contributions.


⚠️ According to the Magento Contribution requirements, all issues must go through the Community Contributions Triage process. Community Contributions Triage is a public meeting.

🕙 You can find the schedule on the Magento Community Calendar page.

📞 The triage of issues happens in the queue order. If you want to speed up the delivery of your contribution, join the Community Contributions Triage session to discuss the appropriate ticket.

✏️ Feel free to post questions/proposals/feedback related to the Community Contributions Triage process to the corresponding Slack Channel

@m2-assistant
Copy link

m2-assistant bot commented Jul 25, 2022

Hi @engcom-Delta. Thank you for working on this issue.
In order to make sure that issue has enough information and ready for development, please read and check the following instruction: 👇

  • 1. Verify that issue has all the required information. (Preconditions, Steps to reproduce, Expected result, Actual result).

    DetailsIf the issue has a valid description, the label Issue: Format is valid will be added to the issue automatically. Please, edit issue description if needed, until label Issue: Format is valid appears.

  • 2. Verify that issue has a meaningful description and provides enough information to reproduce the issue. If the report is valid, add Issue: Clear Description label to the issue by yourself.

  • 3. Add Component: XXXXX label(s) to the ticket, indicating the components it may be related to.

  • 4. Verify that the issue is reproducible on 2.4-develop branch

    Details- Add the comment @magento give me 2.4-develop instance to deploy test instance on Magento infrastructure.
    - If the issue is reproducible on 2.4-develop branch, please, add the label Reproduced on 2.4.x.
    - If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and stop verification process here!

  • 5. Add label Issue: Confirmed once verification is complete.

  • 6. Make sure that automatic system confirms that report has been added to the backlog.

@engcom-Delta engcom-Delta added the Reported on 2.4.4 Indicates original Magento version for the Issue report. label Jul 29, 2022
@engcom-Delta
Copy link
Contributor

Hi @Hexmage ,
Thank you for raising an issue , We tried to reproduce the issue on Magento PWA Venia instance and Magento 2.4.4 instance ,Issue is not reproducible. Hence review provided steps.

Please find the attached reference video.
https://www.loom.com/share/7e2490b4c3fc4f5ca6922c16c81d9e62

@engcom-Delta engcom-Delta added Issue: needs update Additional information is require, waiting for response Issue: Cannot Reproduce Cannot reproduce the issue on the latest `2.4-develop` branch and removed Issue: ready for confirmation labels Jul 29, 2022
@devchris79
Copy link

@Hexmage I just had this issue, I initially tried the fix you suggested but it still reported errors for me.

I got to the root for my instance, we use LiteSpeed cache and when I looked in the admin panel it had dropped back to built in cache (I commented out lines 89-91 of pool.php temporarily). The culprit was somehow our .htaccess was missing this:

<IfModule Litespeed>
    LiteMage on
</IfModule>

When I added this the cache setting selection had reverted back to Litespeed without me reselecting it.
It would seem just as you found that when the expected cache configuration isn't there it crashes.

@Hexmage
Copy link
Author

Hexmage commented Aug 2, 2022

@devchris79 Then I probably know what it was. My staging and live environments run on Varnish. But my develop environment doesn't. But I had synced the config from my staging to my develop environment.

So the real issue is that if a caching method is selected in the configuration that can't work it throws a very awkward error.

@devchris79
Copy link

@Hexmage It would certainly seem that is the case. I am guessing the data provider function getConfigData isn't retrieving an intended null. Maybe the data array element is there but with invalid elements within the config.

 public function getConfigData()
    {
        return $this->data['config'] ?? [];
    }

@devchris79
Copy link

@Hexmage Do you now have an additional entry in your env.php?
Something like:

,
‘cache’ => [
‘graphql’ => [
‘id_salt’ => ‘SALTHERE’
]
]

@devchris79
Copy link

@Hexmage I think your original fix is what's required, I think that I had two issues going on at the same time with Litespeed cache loss provoking your issue.

@richardreen
Copy link

I did change the line in pool.php as described here .
But new error, syntax error....I can not find the error...

syntax error, unexpected '{'#0 /home/user222/domains/xxxxxx.xx/public_html/vendor/composer/ClassLoader.php(428): Composer\Autoload\includeFile('/home/u58658p55...')
#1 [internal function]: Composer\Autoload\ClassLoader->loadClass('Magento\Framewo...')
#2 /home/user222/domains/xxxxxx.xx/public_html/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php(121): spl_autoload_call('Magento\Framewo...')
#3 /home/user222/domains/xxxxxx.xx/public_html/vendor/magento/framework/ObjectManager/Factory/Compiled.php(108): Magento\Framework\ObjectManager\Factory\AbstractFactory->createObject('Magento\Framewo...', Array)
#4 /home/user222/domains/xxxxxx.xx/public_html/vendor/magento/framework/ObjectManager/Factory/Compiled.php(150): Magento\Framework\ObjectManager\Factory\Compiled->create('Magento\Framewo...')
#5 /home/user222/domains/xxxxxx.xx/public_html/vendor/magento/framework/ObjectManager/Factory/Compiled.php(79): Magento\Framework\ObjectManager\Factory\Compiled->get('Magento\Framewo...')
#6 /home/user222/domains/xxxxxx.xx/public_html/vendor/magento/framework/ObjectManager/Factory/Compiled.php(150): Magento\Framework\ObjectManager\Factory\Compiled->create('Magento\Framewo...')
#7 /home/user222/domains/xxxxxx.xx/public_html/vendor/magento/framework/ObjectManager/Factory/Compiled.php(79): Magento\Framework\ObjectManager\Factory\Compiled->get('Magento\Framewo...')
#8 /home/user222/domains/xxxxxx.xx/public_html/vendor/magento/framework/ObjectManager/Factory/Compiled.php(150): Magento\Framework\ObjectManager\Factory\Compiled->create('Magento\Framewo...')
#9 /home/user222/domains/xxxxxx.xx/public_html/vendor/magento/framework/ObjectManager/Factory/Compiled.php(79): Magento\Framework\ObjectManager\Factory\Compiled->get('Magento\Framewo...')
#10 /home/user222/domains/xxxxxx.xx/public_html/vendor/magento/framework/ObjectManager/ObjectManager.php(70): Magento\Framework\ObjectManager\Factory\Compiled->create('Magento\Framewo...')
#11 /home/user222/domains/xxxxxx.xx/public_html/vendor/magento/framework/App/ObjectManager/Environment/Compiled.php(113): Magento\Framework\ObjectManager\ObjectManager->get('Magento\Framewo...')
#12 /home/user222/domains/xxxxxx.xx/public_html/vendor/magento/framework/App/ObjectManagerFactory.php(191): Magento\Framework\App\ObjectManager\Environment\Compiled->configureObjectManager(Object(Magento\Framework\Interception\ObjectManager\Config\Compiled), Array)
#13 /home/user222/domains/xxxxxx.xx/public_html/vendor/magento/framework/App/Bootstrap.php(212): Magento\Framework\App\ObjectManagerFactory->create(Array)
#14 /home/user222/domains/xxxxxx.xx/public_html/vendor/magento/framework/App/Bootstrap.php(127): Magento\Framework\App\Bootstrap->__construct(Object(Magento\Framework\App\ObjectManagerFactory), '/home/user222...', Array)
#15 /home/user222/domains/xxxxxx.xx/public_html/vendor/magento/framework/Console/Cli.php(184): Magento\Framework\App\Bootstrap::create('/home/u58658p55...', Array)
#16 /home/user222/domains/xxxxxx.xx/public_html/vendor/magento/framework/Console/Cli.php(84): Magento\Framework\Console\Cli->initObjectManager()
#17 /home/user222/domains/xxxxxx.xx/public_html/bin/magento(22): Magento\Framework\Console\Cli->__construct('Magento CLI')
#18 {main}

@devchris79
Copy link

@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])) {

@richardreen
Copy link

oke, corrected it and now it runs...no error about syntax error anymore.
Let's see if this is solving the graphql error.

@richardreen
Copy link

now presenting a new error:
Notice: Undefined index: query in /home/u222/domains/xxxxxx.xx/public_html/vendor/magento/module-graph-ql/Controller/GraphQl.php on line 208

and the salt entry still added to env.php

@devchris79
Copy link

That issue with a fix is here: #35412

@richardreen
Copy link

after correcting that, the next error

{"errors":[{"message":"Syntax Error: Unexpected ","extensions":{"category":"graphql"},"locations":[{"line":1,"column":1}]}]}

and 500 error and salt...in the env.php..
still not solved!!

@engcom-Delta
Copy link
Contributor

Hi @Hexmage ,
Are you still facing the same issue ? . Kindly confirm.

Thanks

@Hexmage
Copy link
Author

Hexmage commented Aug 12, 2022

@engcom-Delta
I've implemented my workaround with a patch to avoid the issue. But I'm very confident it's caused by having a caching system configured that doesn't run on your system. eg. Having Varnish configured but don't have any Varnish installed.

@engcom-Delta
Copy link
Contributor

Hi @Hexmage ,
Thank you for the update. Shall we close it ? then?

Regards,

@Hexmage
Copy link
Author

Hexmage commented Aug 18, 2022

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

@engcom-Delta engcom-Delta removed their assignment Aug 22, 2022
@m2-community-project m2-community-project bot removed the Issue: Cannot Reproduce Cannot reproduce the issue on the latest `2.4-develop` branch label Aug 22, 2022
@engcom-Dash engcom-Dash self-assigned this Sep 20, 2022
@m2-assistant
Copy link

m2-assistant bot commented Sep 20, 2022

Hi @engcom-Dash. Thank you for working on this issue.
In order to make sure that issue has enough information and ready for development, please read and check the following instruction: 👇

    1. Verify that issue has all the required information. (Preconditions, Steps to reproduce, Expected result, Actual result).
      DetailsIf the issue has a valid description, the label Issue: Format is valid will be added to the issue automatically. Please, edit issue description if needed, until label Issue: Format is valid appears.
    1. Verify that issue has a meaningful description and provides enough information to reproduce the issue. If the report is valid, add Issue: Clear Description label to the issue by yourself.
    1. Add Component: XXXXX label(s) to the ticket, indicating the components it may be related to.
    1. Verify that the issue is reproducible on 2.4-develop branch
      Details- Add the comment @magento give me 2.4-develop instance to deploy test instance on Magento infrastructure.
      - If the issue is reproducible on 2.4-develop branch, please, add the label Reproduced on 2.4.x.
      - If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and stop verification process here!

@engcom-Dash
Copy link
Contributor

Hi @Hexmage,

We are checking the issue with 2.4-develop instance and we are not able to reproduce the issue because we are getting expected result....

Screenshots:
Screenshot from 2022-09-20 15-02-44
4

Steps:
1.install Magento instance
2.Update the instance using composer update command
3.Composer update completed successfully

Let us know if we missing anything!!!

Thanks!!!

@Hexmage
Copy link
Author

Hexmage commented Sep 20, 2022

@engcom-Dash Did you configure Varnish on the server before upgrade but don't actually have varnish installed?

This is what I believe results in the error. Also it only showed when running bin/magento

@RajasekarPanneerselvam
Copy link

@magento give me 2.4-develop instance

@engcom-Dash
Copy link
Contributor

@magento give me 2.4-develop instance

@magento magento deleted a comment from magento-deployment-service bot Oct 19, 2022
@magento magento deleted a comment from magento-deployment-service bot Oct 19, 2022
@engcom-Dash
Copy link
Contributor

@magento give me 2.4-develop instance

@magento-deployment-service
Copy link

Hi @engcom-Dash. Thank you for your request. I'm working on Magento instance for you.

@magento-deployment-service
Copy link

@engcom-Dash
Copy link
Contributor

Hi @Hexmage ,

As per your instructions we enabled varnish on the server before upgrade...Even though we getting the same results.

Screenshots:
Screenshot 2022-10-19 at 6 01 28 PM

Let us know if we missing anything!!!

Thanks!

@Hexmage
Copy link
Author

Hexmage commented Oct 19, 2022

@engcom-Dash
I've had the issue happen to multiple different shops between 2.4.4 and 2.4.5. But I have no clue how the effectively reproduce it on a clean installation.

@engcom-Dash
Copy link
Contributor

Hi @Hexmage ,

We tried both Local and cloud instance we are same results...Any how we will try once with fresh installation and will update you ASAP.

Thanks!!!

@Hexmage
Copy link
Author

Hexmage commented Oct 31, 2022

@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.

@devchris79
Copy link

@engcom-Dash
This is the same issue as #35861

@engcom-Dash
Copy link
Contributor

Hi @devchris79 ,

We are Closing this issue seems its like duplicate https://github.com/magento/magento2/issues/35861

Let us know if we missing anything!!!

Thanks!

@mreichenbach-igniti
Copy link

mreichenbach-igniti commented Nov 7, 2022

@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?

@richardreen
Copy link

richardreen commented Nov 7, 2022 via email

@jmonrove
Copy link

jmonrove commented Dec 6, 2022

Just happened to me on 2.4.5-p1, problem is still there

@munkhulzii
Copy link

munkhulzii commented Dec 7, 2022

I had this issue also with 2.4.5-p1.
In system.log I see the error message
`main.ERROR: Syntax Error: Unexpected

GraphQL (1:1)
1:
^
[] []
`
and after that the shop was down.

fixed temporarily remove the hash from env.php

@munkhulzii
Copy link

munkhulzii commented Dec 7, 2022

Found out the reason, it happens if the env.php does not have the cache -> frontend node. After the cache configuration was added correctly the issue does not appear anymore.
So the solution is, you have to configure cache config correctly in env.php!

@Hexmage
Copy link
Author

Hexmage commented May 17, 2023

@engcom-Dash
We have known the cause of the issue for a while now, but I don't think it's fixed in the latest version yet.

So if your app/etc/env.php doesn't contain a cache -> frontend node yet (which it doesn't on a new install). And you visit the /graphql endpoint. The shop breaks.

This is caused because the call to the graphql endpoint creates a cache -> graphql node in the env. But the ./vendor/magento/framework/App/Cache/Frontend/Pool.php class expects the frontend node to always exists when the cache node exists. Which clearly isn't the case.

@erikvandermey
Copy link

I just started encountering this issue on a fresh 2.4.6-p1 build. Hitting the /graphql/ url kills the site.

Short of installing Varnish and enabling cache to get the needed node inserted into env.php, does someone have the snippet of code for env.php that would prevent this error from happening?

@experius-nl
Copy link

@erikvandermey

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

There might already be a different value in the cache node (hence why the error is triggering), but adding an empty frontend node in addition to the other nodes already there fixes the issue.

@hostep
Copy link
Contributor

hostep commented Oct 24, 2023

Ran into this using Magento 2.4.6-p3
Workaround by adding frontend => [] works.

I don't understand why this issue got closed though. @engcom-Dash: it got closed because it's a duplicate of #35861 and #35861 got closed because it's a duplicate of this issue, that makes little sense? One of both should remain open, otherwise it can't be picked up.
This should be a pretty high prio issue (P0 or P1). We just had this happened a couple of hours after a deploy where everything went fine, it's just after some hours when a specific url got hit that we got that graphql => id_salt added to the env.php file. And that broke the entire shop...

Or has it already been fixed on 2.4-develop in the mean while? If yes: can somebody share some info or a commit?

@hostep
Copy link
Contributor

hostep commented Oct 24, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Issue: needs update Additional information is require, waiting for response Reported on 2.4.4 Indicates original Magento version for the Issue report.
Projects
None yet
Development

Successfully merging a pull request may close this issue.