-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Adding in customisable exclude paths in setup:di:compile #20485
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
Conversation
Attempt to make the debugging a little easier when the system configuration is incorrect. Needed to add the App state class and the Logger to determine how much logging is used and how to get the error to the end developer or user. Updated the PHPUnit test to have logger and state mocks. Included a Unit test for confirming the exception message in developer mode.
… or import the class at the top, but it isn't common to see in core code.
…1-No-CLI-option-to-exclude-patterns-on-setup-di-compile-and/idi-p/48447 Added event dispatch with excluded patterns so observers can exclude specific custom paths when running setup:di:compile. Ideally, because this forces the vendors to acknowledge that the compilation isn't working, they will be prompted to fix the actual issue instead of simply excluding the problem.
Updating 2.3-develop branch with magento2/2.3-develop branch
Hi @PivitParkour94. Thank you for your contribution
For more details, please, review the Magento Contributor Assistant documentation |
Current implementation excludes tests magento2/setup/src/Magento/Setup/Console/Command/DiCompileCommand.php Lines 143 to 154 in 989af63
|
Hi @PivitParkour94, thank you for your contribution! |
@orlangur We have in some modules a directory "Example", that contains some standalone php files. They are also to check some connectivity. One example: Simple SOAP-Queries. On each Cause we can not use plugins here and a di.xml-argument passing Also there was such an option #986 |
Hi @PivitParkour94. Thank you for your contribution
For more details, please, review the Magento Contributor Assistant documentation |
@jwundrak why not put them in |
Sure, an option. I have noticed, you don't want this option and that is ok. Thanks for answer. I close this request again. |
Hi @PivitParkour94, thank you for your contribution! |
Thanks for understanding @jwundrak. Main problem I see is that with such option we can unintentionally affect classes in some other module rather the one we want to exclude from compilation. |
@jwundrak I've given up trying to help make Magento open source better for developers. It is clear that Magento is focusing on the Commerce market and I wouldn't be surprised if the Open Source dev is frustratingly difficult intentionally, to help incentivise the upgrade to Commerce. Such is life, I suppose. |
@PivitParkour94 could you please be more specific? This particular decision makes Magento BETTER for developers. You need to do things properly instead of adding some hacks/flags/exclusions here and there. |
@orlangur I completely agree, however, we've noticed that almost every 3rd party module developer including modules that are bundled in with the core, don't always follow those practices, which means that we then have to patch OTHER's code to change the "hacks/flags/exclusions here and there" simply because the flexibility isn't there. I am simply offering a solution to account for the code that isn't up to standard while still allowing a development workflow that doesn't break the entire pipeline.
I've made a number of different Pull Requests, which takes effort and they have been declined and it's just gotten to the point where we maintain a bunch of patches to core that we have to update ourselves with each new version. It's not as though I'm suggesting a change that forces everyone to change, but rather accommodates those edge cases in which the 0.1% of developers have previously been restricted. @jwundrak has shown a gist that achieves very similar functionality so clearly this issue effects at least both of our environments. |
This is something core developers are being working on hard now. Trying to catch as much guidekines violations as possible. |
@orlangur even if that is the case, nothing is going to stop 3rd party developers from trying to force their own development practices into the modules rather than take the time to learn how Magento 2 should be developed and extended. It's clear that this is not going to be solved and we'll just have to deal with it. Having said that, in a perfect world everyone would develop according to the standards and things would never break, but this is Software Dev, far from a perfect world. |
I have a real-world use case. In our Magento instance, we use a 3rd party module called mconnect. It is installed (via composer), and it is used by a custom module (MConnect) in our source tree. mconnect is installed only in staging and production environments. This is partly due to licensing, and partly because it syncs data with other systems - we don't want to impact these systems from our dev instances. In development, we simply leave MConnect disabled. However, running |
You clearly don't need it on dev instances. So either strip it during deploy on dev or add it dynamically during deploy on staging/production. |
The rule of thumb is simple: don't keep in source code what you actually don't use. As a side effect you may avoid a lot of troubles. |
Description (*)
There has been lots of demand for extending the di compilation exclude paths (either via CLI options or events) so I decided to add in an event
setup_di_compile_excluded_patterns
that can be observed and added to from within a third-party module.Fixed Issues (if relevant)
Manual testing scenarios (*)
bin/magento setup:di:compile
and see it compiles as expected despite the bad code in the module file.Contribution checklist (*)
Notes
There are a bunch of commits on here, but as you can tell from the diff, those proposed changes that were rejected previously have been reverted. This simply updates the setup:di:compile to give the ability to exclude custom paths via an observer.