magento / magento/community-features
Module ordering for modules without parent dependencies should be loaded in a consistent manner
Nobody has claimed this yet.
- Dominant language
- No language data
- Stars
- 46
- Forks
- 14
- PR merge metrics
- No merged PRs in 30d
Description
Summary
Module ordering for modules without parent dependencies should be loaded in a consistent manner. Currently, it is very random and can cause issues that are unrelated to changes made within a release, thus making them very hard to debug.
Examples
We have hit this twice in the last month. We inherited a codebase that does not correctly set module dependencies in most of its custom modules. Everything works correctly until something causes the module order in app/etc/config.php to change. Modules tend to get rearranged significantly with any small change.
Examples we ran into:
- Cart page was empty because there was a module that should have depended on Magento_Checkout that didn't. This module had a bad layout override that replaced a block in checkout, but it was not a visible issue because it loaded before the Magento checkout module. It used to be included (randomly) before it; after the deploy it was included randomly after it. We ended up having to fix this by fixing the layout, but the point is that the error presented itself randomly due to unrelated changes in the release.
- PDP swatch images were being rendered as very small images, then stretched causing them to be very pixellated. Same reason for the issue as above; It surfaced on a release due to random module sort order.
Proposed solution
While declaring dependencies in module.xml files is the correct fix, this is not always possible with inherited code. I think module loading could be less unreliable in this scenario if we added some consistent rules around loading modules without declared child dependencies.
I propose a ruleset similar to this:
- Determine dependency order based on declared dependencies in module.xml files.
- Where there is ambiguity and modules are at the same level in the dependency tree, load them in alphabetic order.
- All modules without child dependencies should load last in alphabetic order
Alphabetic ordering would prevent the random sort issues we are seeing. Modules could continue to incorrectly not have module dependencies declared but still have consistent behavior across releases except in the case where we specifically change a related module.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Review declared dependencies in module.xml files and how they produce app/etc/config.php; start by tracing the module ordering logic. Done means modules with ambiguous or absent child dependencies follow a documented, repeatable ordering, and unrelated changes no longer rearrange them unpredictably.
Written by the indexing model from the issue text.
Assessment
- Domain
- backend
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100