Skip to content

[Issue] Remove unnecessary cache manipulation during setup #38124

@m2-assistant

Description

@m2-assistant

This issue is automatically created based on existing pull request: #38123: Remove unnecessary cache manipulation during setup


Description

When running bin/magento setup:db-data:upgrade (or bin/magento setup:upgrade), Magento turns off some caches, then re-enables the same. This causes Magento to write out its configuration to disk, but this step seems unnecessary and is causing some issues with downstream modules which observe this event (write deployment configuration to disk) because it is not necessary at this step. Relevant caches are already cleared later on in the process, so turning them off and then back on again seems redundant.

I can't work out why this was added. The best I can find is the initial commit (96a2e17), which says "MC-30236: Upgrade from 2.3.x CE with SD to 2.3.x EE AreaCode Exception". MC-30263 seems like a reference to a ticket, but I don't have any visibility on this. I don't see any tests associated with this commit to demonstrate the bug it claims to resolve. The description of the supposed bug ("AreaCode Exception") suggests that this action (disable/enable caches) is not the correct resolution anyway. This pull request effectively removes all changes related to that ticket from this repository.

For my reference later, the specific case which we were investigating (which lead me back to this) was https://gitlab.hyva.io/hyva-themes/magento2-theme-module/-/blob/main/src/Plugin/HyvaModulesConfig/UpdateOnModuleStatusChange.php?ref_type=heads#L40 being called during during deployment, which over-wrote the file we stored in version control.

Manual testing scenarios

  1. Environment file gets regenerated as expected.
    1. Add a code comment to app/etc/env.php
    2. Run bin/magento cache:disable layout && bin/magento cache:enable
    3. Review the content of app/etc/env.php to see that the file has been regenerated.
  2. Environment file does not get regenerated during setup commands
    1. Add a code comment to app/etc/env.php
    2. Run bin/magento setup:db-data:upgrade
    3. Review the content of app/etc/env.php to see that the file has not been modified.
    4. Run bin/magento setup:upgrade
    5. Review the content of app/etc/env.php to see that the file has not been modified.

Questions or comments

I am happy to learn more about why this code was initially added. It may be that the bug this was intended to fix no longer exists, or that there is a better way to fix that bug if it still remains.

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)

Metadata

Metadata

Assignees

Labels

Area: FrameworkIssue: ConfirmedGate 3 Passed. Manual verification of the issue completed. Issue is confirmedPriority: P2A defect with this priority could have functionality issues which are not to expectations.Progress: doneReproduced on 2.4.xThe issue has been reproduced on latest 2.4-develop branchTriage: Dev.ExperienceIssue related to Developer Experience and needs help with Triage to Confirm or Reject it

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions