magento2 icon indicating copy to clipboard operation
magento2 copied to clipboard

[2.4.4] Missing Frontend CacheInfo breaks bin/magento

Open Hexmage opened this issue 2 years ago • 21 comments

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

  • [X] 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”.

Hexmage avatar Jul 25 '22 15:07 Hexmage

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.


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

:clock10: You can find the schedule on the Magento Community Calendar page.

:telephone_receiver: 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.

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

m2-assistant[bot] avatar Jul 25 '22 15:07 m2-assistant[bot]

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: :point_down:

  • [ ] 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.

m2-assistant[bot] avatar Jul 25 '22 15:07 m2-assistant[bot]

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 avatar Jul 29 '22 08:07 engcom-Delta

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

devchris79 avatar Aug 02 '22 11:08 devchris79

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

Hexmage avatar Aug 02 '22 13:08 Hexmage

@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 avatar Aug 02 '22 13:08 devchris79

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

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

devchris79 avatar Aug 02 '22 14:08 devchris79

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

devchris79 avatar Aug 04 '22 10:08 devchris79

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}

richardreen avatar Aug 05 '22 07:08 richardreen

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

devchris79 avatar Aug 05 '22 08:08 devchris79

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

richardreen avatar Aug 05 '22 08:08 richardreen

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

richardreen avatar Aug 05 '22 08:08 richardreen

That issue with a fix is here: #35412

devchris79 avatar Aug 05 '22 09:08 devchris79

after correcting that, the next error

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

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

richardreen avatar Aug 05 '22 09:08 richardreen

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

Thanks

engcom-Delta avatar Aug 09 '22 12:08 engcom-Delta

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

Hexmage avatar Aug 12 '22 08:08 Hexmage

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

Regards,

engcom-Delta avatar Aug 18 '22 08:08 engcom-Delta

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

Hexmage avatar Aug 18 '22 08:08 Hexmage

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: :point_down:

    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!

m2-assistant[bot] avatar Sep 20 '22 09:09 m2-assistant[bot]

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!!!

engcom-Dash avatar Sep 20 '22 10:09 engcom-Dash

@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

Hexmage avatar Sep 20 '22 13:09 Hexmage

@magento give me 2.4-develop instance

RajasekarPanneerselvam avatar Oct 18 '22 11:10 RajasekarPanneerselvam

@magento give me 2.4-develop instance

engcom-Dash avatar Oct 19 '22 12:10 engcom-Dash

@magento give me 2.4-develop instance

engcom-Dash avatar Oct 19 '22 12:10 engcom-Dash

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

Hi @engcom-Dash, here is your Magento Instance: https://a0c7ab63ae156afb6b38ad4d58baf5ee.instances.magento-community.engineering Admin access: https://a0c7ab63ae156afb6b38ad4d58baf5ee.instances.magento-community.engineering/admin_505d Login: 24bf950b Password: a05739bdfed7

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!

engcom-Dash avatar Oct 19 '22 12:10 engcom-Dash

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

Hexmage avatar Oct 19 '22 12:10 Hexmage

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!!!

engcom-Dash avatar Oct 20 '22 10:10 engcom-Dash

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

Hexmage avatar Oct 31 '22 15:10 Hexmage