magento / magento2

Prior to making any Submission(s), you must sign an Adobe Contributor License Agreement, available here at: https://opensource.adobe.com/cla.html. All Submissions you make to Adobe Inc. and its affiliates, assigns and subsidiaries (collectively “Adobe”) are subject to the terms of the Adobe Contributor License Agreement.
http://www.magento.com
Open Software License 3.0
11.54k stars 9.32k forks source link

[Issue] Dependency checker does not work properly when enabling modules #38606

Open m2-assistant[bot] opened 6 months ago

m2-assistant[bot] commented 6 months ago

This issue is automatically created based on existing pull request: magento/magento2#38600: Dependency checker does not work properly when enabling modules


Description (*)

Enabling / disabling modules is prepared to avoid leaving modules status in a inconsistent state, regarding its dependencies declared in composer.json, so:

Given Module_A and Module_B, and a declared relation of Module_B => Module_A, I should not be able to enable Module_B without enabling Module_A, but I am:

❯ bin/magento module:disable Module_B Module_A
No modules were changed.
❯ bin/magento module:enable Module_B
The following modules have been enabled:
- Module_B

Cache cleared successfully.
Generated classes cleared successfully. Please run the 'setup:di:compile' command to generate classes.
Info: Some modules might require static view files to be cleared. To do this, run 'module:enable' with the --clear-static-content option to clear them.

Technical Details

DependencyChecker needs to use a PackageInfo instance that uses FullModuleList (as already done at ConflictChecker::__construct) in order to work, so constructor is changed to use PackageInfoFactory::create() implementation which creates PackageInfo instance with FullModuleList embedded (instead of standard ModuleList).

Related Pull Requests

None AFAIK.

Fixed Issues (if relevant)

None AFAIK.

Manual testing scenarios (*)

  1. Create 2 simple modules in app/code, Module_A and Module_B; only registration.php, module.xml and composer.json files are required.
{
    "name": "module/module-a",
    "require": {
    }
}
{
    "name": "module/module-b",
    "require": {
        "module/module-a": "*"
    }
}
  1. Try disabling both modules, then enabling the dependent one without enabling the dependency.

Before the change:

❯ bin/magento module:disable Module_B Module_A
No modules were changed.
❯ bin/magento module:enable Module_B
The following modules have been enabled:
- Module_B

Cache cleared successfully.
Generated classes cleared successfully. Please run the 'setup:di:compile' command to generate classes.
Info: Some modules might require static view files to be cleared. To do this, run 'module:enable' with the --clear-static-content option to clear them.

After the change:

❯ bin/magento module:disable Module_B Module_A
No modules were changed.
❯ bin/magento module:enable Module_B
Unable to change status of modules because of the following constraints:
Cannot enable Module_B because it depends on disabled modules:
Module_A: Module_B->Module_A

The other case keeps working:

❯ bin/magento module:enable Module_A Module_B
The following modules have been enabled:
- Module_A
- Module_B

Cache cleared successfully.
Generated classes cleared successfully. Please run the 'setup:di:compile' command to generate classes.
Info: Some modules might require static view files to be cleared. To do this, run 'module:enable' with the --clear-static-content option to clear them.
❯ bin/magento module:disable Module_A
Unable to change status of modules because of the following constraints:
Cannot disable Module_A because modules depend on it:
Module_B: Module_B->Module_A

Questions or comments

Contribution checklist (*)

m2-assistant[bot] commented 6 months ago

Hi @engcom-November. 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:

engcom-November commented 6 months ago

Hello @adrian-martinez-onestic,

Thank you for the report and collaboration!

Verified this on 2.4-develop. With Module_B being dependent on Module_A, we cannot enable Module_B without enabling Module_A. Hence this issue can be confirmed.

Thank you.

github-jira-sync-bot commented 6 months ago

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

m2-assistant[bot] commented 6 months ago

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