Skip to content
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

[Issue] Don't assume a frontend cache section exists in the env.php file. #38363

Closed
3 of 5 tasks
m2-assistant bot opened this issue Jan 18, 2024 · 2 comments · Fixed by #38119
Closed
3 of 5 tasks

[Issue] Don't assume a frontend cache section exists in the env.php file. #38363

m2-assistant bot opened this issue Jan 18, 2024 · 2 comments · Fixed by #38119
Assignees
Labels
Area: Framework Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Priority: P2 A defect with this priority could have functionality issues which are not to expectations. Progress: done Reported on 2.4.x Indicates original Magento version for the Issue report. Reproduced on 2.4.x The issue has been reproduced on latest 2.4-develop branch

Comments

@m2-assistant
Copy link

m2-assistant bot commented Jan 18, 2024

This issue is automatically created based on existing pull request: #38119: Don't assume a frontend cache section exists in the env.php file.


Description (*)

Code exists in Magento that assumes your app/etc/env.php will always contain a frontend section if there is a cache section. Like this:

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

But that's not always the case. All shops that were setup before Magento 2.3.1 didn't have a cache section in their env.php file in a default installation (if they didn't use Redis as caching).
If they now upgrade to Magento 2.4.4 or higher and use a graphql endpoint, Magento automatically writes cache > graphql > id_salt to the env.php file and so introduces a cache section without a frontend section.

This then leads to this crash on every execution within Magento (frontend, backoffice, bin/magento, ...):

Warning: Undefined array key "frontend" in lib/internal/Magento/Framework/App/Cache/Frontend/Pool.php on line 90

This PR fixes this.

Related Pull Requests

Fixed Issues (if relevant)

  1. Fixes [2.4.4] Missing Frontend CacheInfo breaks bin/magento #35812
  2. Fixes graphql id_salt causing 500 server errors #35861

Manual testing scenarios (*)

  1. Fully setup a working Magento
  2. Edit the app/etc/env.php file and remove the entire frontend section in the cache section
  3. Run bin/magento or visit the frontend
  4. Expected is to not see an error/crash
  5. Run added unit test with and without fix. Without the fix, the test will fail (vendor/bin/phpunit -c dev/tests/unit/phpunit.xml.dist lib/internal/Magento/Framework/App/Test/Unit/Cache/Frontend/PoolTest.php)

More elaborate testing scenario that can cause this situation:

  1. Using PHP 7.2 and composer v1, setup Magento 2.3.0 and install it fully (don't configure it with Redis caching)
  2. Double check that the app/etc/env.php file contains no cache section
  3. Using PHP 8.2 and composer v2, upgrade this installation to Magento 2.4.6-p3 (or 2.4-develop)
  4. Run bin/magento setup:upgrade
  5. Your app/etc/env.php file will be updated to a new format, but will still not contain a cache section.
  6. Confirm that Magento works correctly
  7. On the frontend visit the /graphql url
  8. Check your app/etc/env.php file and see that a cache section has appeared with a graphql section but no frontend section
  9. Visit the homepage or run bin/magento
  10. See errors/crashes

Questions or comments

Should we expect that when we run bin/magento setup:upgrade it will update your app/etc/env.php file with all missing sections? Would people expect this? Or will this cause issues in some scenario's? Running bin:magento setup:config:set without extra flags does exactly that. That seems to be some kind of hidden feature ...

Contribution checklist (*)

  • Pull request has a meaningful description of its purpose
  • All commits are accompanied by meaningful commit messages
  • All new or changed code is covered with unit/integration tests (if applicable)
  • README.md files for modified modules are updated and included in the pull request if any README.md predefined sections require an update
  • All automated tests passed successfully (all builds are green)
@m2-assistant m2-assistant bot added the Priority: P2 A defect with this priority could have functionality issues which are not to expectations. label Jan 18, 2024
@m2-community-project m2-community-project bot added this to Ready for Development in High Priority Backlog Jan 18, 2024
@m2-community-project m2-community-project bot moved this from Ready for Development to Pull Request In Progress in High Priority Backlog Jan 18, 2024
@m2-community-project m2-community-project bot moved this from Pull Request In Progress to Done in High Priority Backlog Jan 18, 2024
@engcom-Hotel engcom-Hotel added Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Reproduced on 2.4.x The issue has been reproduced on latest 2.4-develop branch Progress: PR in progress Progress: ready for dev Reported on 2.4.x Indicates original Magento version for the Issue report. Area: Framework and removed Progress: done labels Jan 18, 2024
@github-jira-sync-bot
Copy link

✅ Jira issue https://jira.corp.adobe.com/browse/AC-10865 is successfully created for this GitHub issue.

Copy link
Author

m2-assistant bot commented Jan 18, 2024

✅ Confirmed by @engcom-Hotel. Thank you for verifying the issue.
Issue Available: @engcom-Hotel, You will be automatically unassigned. Contributors/Maintainers can claim this issue to continue. To reclaim and continue work, reassign the ticket to yourself.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Framework Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Priority: P2 A defect with this priority could have functionality issues which are not to expectations. Progress: done Reported on 2.4.x Indicates original Magento version for the Issue report. Reproduced on 2.4.x The issue has been reproduced on latest 2.4-develop branch
Projects
Development

Successfully merging a pull request may close this issue.

3 participants