-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Sequence of module load order should be deterministic #8479
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
Comments
While I agree that seemingly random order in config.php may lead to unexpected side-effects, and that it might be a good idea to versionize it is well (also in order to track which modules should be enabled), you have to also consider that this file is in fact re-generated by Magento whenever you enable or disable a module based on modules' tags (more on that here ) thus purely alphabetical is just not an option. (I'm sincerely sorry if I misunderstood your point, please do correct me If I missed something) |
@korostii, I know this file is regenerated every time you enable/disable a module. That's why I'm suggesting that the order be deterministic. That way when it's regenerated, the only change between the old version and the new version is the relevant line. Before I created the issue I read through the code handling |
In case others find it helpful, this one-liner will show you the real changes in the
|
I was previously incorrect about |
Like which?
Agree, but what is the problem in lines reordering? I hope nobody is changing
Please describe a real-world scenario where such order does make sense. What would be the value of such behavior if it is possible to be implemented? When we are talking about just one module added criteria is pretty easy - "put module in earliest possible spot" or "as close to tail of module list as possible". But I'm pretty confused by what do you mean by "deterministic" in common case, when multiple modules could be enabled, containing some TL;DR From my understanding composer already have all we need to declare correct order of modules since composer/composer#655 (comment) and it would be good to deprecate |
@orlangur I agree that the
Consistency does not require any specific order (short of the implicit dependencies as mentioned in #10649), but traceability does (to do it easily). Ideally I should be able to do a
If sequencing for modules change, I would expect to see the sequence in By determinacy I mean at a minimum "stability" as discussed in #10649, but more than that. Stability only says that the order of equal keys will be preserved after sorting; determinacy (as I'm using it) would mean that even given a random initial state, the same order would always result after sorting. This would require sorting on more than just the |
Granted, in most cases true stability would be enough to keep the commit diffs on the file to a minimum. Determinacy as I described it would be ideal but only relevant in the off case that the same change is introduced by two different developers. Even that would likely introduce a git conflict, but at least it would be more obvious how to merge than if the modules ended up sorted differently. |
@scottsb Thank you for your submission. |
@scottsb, thank you for your report. |
We had a similar issue, where the ordering of modules changing was causing us problems, this is the solution we came up with: <>, allowing it to change in development mode and when running anything other than setup:upgrade (as setup:upgrade is the only command that can change this and should be run on live) |
@adamzero1 please propose changes creating a pull request instead of posting some patch links. |
Hi @scottsb. Thank you for your report.
The fix will be available with the upcoming 2.2.9 release. |
Uh oh!
There was an error while loading. Please reload this page.
Preconditions
Magento 2.1.3
Steps to reproduce
config.php
.Expected result
The only change to
config.php
is the addition of the module that changed.Actual result
In addition to the new line for the new module, many other lines change sequence.
Discussion
It seems that the current semi-official recommendation is not to version the
config.php
file with the code base and to treat it as an asset along with images, as evidenced by the fact that it is git-ignored in the Magento repository by default and by the fact this advice is upvoted and without alternative:http://magento.stackexchange.com/a/130109/567
If I understand the intent behind this recommendation, it's that one should be able to pull the latest copy of the code without immediately breaking the site due to an incompatible database schema. My counterpoint is that since themes and existing modules may be modified to depend on certain new modules being enabled, pulling code without including
config.php
is just as likely to break a site.Ultimately whether
config.php
is versioned or not is probably a decision best made by each individual implementor. However, for us, it definitely makes sense to version it. It allows us to have one atomic unit of enabled code to test and deploy from dev through to production. I know others will agree, given the comments on #800 and the original Stack Exchange question referenced above.Given that, in order to minimize merge conflicts, it would be best for the sequence of modules in
config.php
to be deterministically generated. It appears that currently it is based on the module load order, but that is not fully deterministic.Since the sequence of modules inconfig.php
is not itself used to determine any programatic behavior, my suggestion is that the array be sorted alphabetically by key, but I would consider any deterministic ordering to meet the goal.The text was updated successfully, but these errors were encountered: