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

Dependency checker does not work properly when enabling modules #38600

Open
wants to merge 5 commits into
base: 2.4-develop
Choose a base branch
from

Conversation

adrian-martinez-onestic
Copy link

@adrian-martinez-onestic adrian-martinez-onestic commented Apr 10, 2024

Description (*)

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

  • It should not allow disabling a module that enabled modules depend on. (This case is working properly)
  • It should not allow enabling a module that depends on a disabled module. (This case is not working)

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 (*)

  • 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)

Resolved issues:

  1. resolves [Issue] Dependency checker does not work properly when enabling modules #38606: Dependency checker does not work properly when enabling modules

DependencyChecker needs to use a PackageInfo instance that uses FullModuleList (as already done at \Magento\Framework\Module\ConflictChecker::__construct) in order to work, so use \Magento\Framework\Module\PackageInfoFactory::create which creates instance properly
Copy link

m2-assistant bot commented Apr 10, 2024

Hi @adrian-martinez-onestic. Thank you for your contribution!
Here are some useful tips on how you can test your changes using Magento test environment.

Add the comment under your pull request to deploy test or vanilla Magento instance:
  • @magento give me test instance - deploy test instance based on PR changes
  • @magento give me 2.4-develop instance - deploy vanilla Magento instance

❗ Automated tests can be triggered manually with an appropriate comment:

  • @magento run all tests - run or re-run all required tests against the PR changes
  • @magento run <test-build(s)> - run or re-run specific test build(s)
    For example: @magento run Unit Tests

<test-build(s)> is a comma-separated list of build names.

Allowed build names are:
  1. Database Compare
  2. Functional Tests CE
  3. Functional Tests EE
  4. Functional Tests B2B
  5. Integration Tests
  6. Magento Health Index
  7. Sample Data Tests CE
  8. Sample Data Tests EE
  9. Sample Data Tests B2B
  10. Static Tests
  11. Unit Tests
  12. WebAPI Tests
  13. Semantic Version Checker

You can find more information about the builds here
ℹ️ Run only required test builds during development. Run all test builds before sending your pull request for review.


For more details, review the Code Contributions documentation.
Join Magento Community Engineering Slack and ask your questions in #github channel.

@engcom-Hotel
Copy link
Contributor

@magento create issue

@engcom-Hotel engcom-Hotel added the Priority: P2 A defect with this priority could have functionality issues which are not to expectations. label Apr 10, 2024
@adrian-martinez-onestic
Copy link
Author

@magento run all tests

@adrian-martinez-onestic
Copy link
Author

@magento run Unit Tests

@adrian-martinez-onestic
Copy link
Author

@magento run all tests

@adrian-martinez-onestic
Copy link
Author

@magento run all tests

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Priority: P2 A defect with this priority could have functionality issues which are not to expectations. Progress: pending review
Projects
Pull Requests Dashboard
  
Pending Review
Development

Successfully merging this pull request may close these issues.

[Issue] Dependency checker does not work properly when enabling modules
2 participants