Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.7k
Introduce weak vendors mode#21539
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
nicolas-grekas commentedFeb 5, 2017 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
I see two issues here:
|
greg0ire commentedFeb 5, 2017 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
|
| $trace =debug_backtrace(true); | ||
| $group ='other'; | ||
| $isVendor = (strpos($file,'/vendor/') !==false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
@nicolas-grekas : we're outside the while on$trace here, so really, we're not looking at every file of the stack trace, but only at the file that has the error triggered in it.
greg0ire commentedFeb 5, 2017
Third issue, even more minor, some people might have a |
nicolas-grekas commentedFeb 5, 2017
That means you target deprecations triggered by code in src/. Ok. For vendors, see my PR about ComposerResource. |
greg0ire commentedFeb 5, 2017
Actually that was wrong and has nothing to do with the stack trace, I'm looking at the |
greg0ire commentedFeb 5, 2017
|
ogizanagi commentedFeb 5, 2017
greg0ire commentedFeb 5, 2017 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Maybe I should explain a bit more the goal of this PR, I feel I'm being unclear. This is going to used way more in libs than in project, that seldom use deprecation notices themselves.@nicolas-grekas I think that's why you talk about userland vs vendors. Let there be lib X, that has n dependencies. Anytime any of the n dependencies introduces a new deprecation, I have to fix it, andno PR can be merged during that time, unless I use And that's what I do most of the time, because I don't want to shift the burden of fixing these to anyone who wants to contribute anything unrelated to the vendor lib, and has the bad luck of doing so at the wrong time. Now let's suppose a contributor submits a new PR, and let's suppose that that PR introduces a deprecation notice inthe codebase of the lib , and by that I don't mean a deprecated call to another lib, I mean a call to In my experience, many people forget to do that, and deprecations are introduced, that could easily be avoided. Seethis PR where I end up doing the work that should have been done by the contributor from the start. |
nicolas-grekas commentedFeb 6, 2017
Doc PR would be really nice before merging since the use case should be explained there :) |
stof commentedFeb 6, 2017
@greg0ire the issue is that your logic looks wrong. Vendor deprecations must not be distinguished based on the location of the deprecation, but based on the caller location. |
greg0ire commentedFeb 6, 2017 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
That's precisely the case I'm trying to help fix however.There are contributors that contribute new deprecations, and forget to fix these calls. Then it get merged, but could have easily be prevented. Also, there are tests that are marked with
I'm not doing that (I think). I'm not indentify the caller location, I'm identifying the callee location. When developing a lib, the lib is always calling others or itself, but no other lib is calling my lib. So in that case, I think it's safe to want to know "is there any call to a deprecated methodof my lib in the codebaseof my lib?"
|
greg0ire commentedFeb 6, 2017
Didn't notice your comment. Will do! |
greg0ire commentedFeb 7, 2017
nicolas-grekas commentedFeb 7, 2017
Thanks, just posted a few short notes |
| $mode =getenv('SYMFONY_DEPRECATIONS_HELPER'); | ||
| } | ||
| if (DeprecationErrorHandler::MODE_WEAK !==$mode && (!isset($mode[0]) ||'/' !==$mode[0])) { | ||
| if (!in_array($mode,array( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Missingtrue as a 3rd parameter forin_array:https://3v4l.org/hsgBm
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
fixed, thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
the in_array + line splits look unreadable to me - what about using two comparisons on a single line instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
I think it's a matter of taste, because to me the more readable version is of course mine. Plus it's less repetitive. I'll do as you say though, b/c you're probably more aware of what the sf style is.
greg0ire commentedFeb 8, 2017
I changed the code so that other modes output is no longer split into vendors / non-vendors. |
028a816 tobd8f0b3Comparegreg0ire commentedFeb 8, 2017
I fixed the colorization issue, deprecation notices are always in yellow now. |
fabpot commentedFeb 12, 2017
fabbot reports errors that should be fixed. |
greg0ire commentedFeb 12, 2017
@fab{b,p}ot : fixed |
greg0ire commentedFeb 21, 2017
I rebased again, can anyone review and remove the "Needs work" label? This is supposed to be finished. |
greg0ire commentedFeb 21, 2017
Changed the poor man's error handler from |
| $colorize =function ($str) {return$str; }; | ||
| } | ||
| if ($currErrorHandler !==$deprecationHandler) { | ||
| print_r(error_get_last()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
unrelated, and very fragile to me, should be removed from this PR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Ok let's remove it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Not sure what exactly qualifies as fragile here though. I think both methods are rock solid.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
the link betweenerror_get_last() and the error handler change - maybe I'm wrong - it's still unrelated so please open another PR if you want to investigate the idea
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Unrelated indeed. Will do
A new mode is introduced, in which deprecations coming from the vendorsare not taken into account when deciding to exit with an error code. Inthis mode, deprecations coming from the vendors are segregated fromother deprecations.
greg0ire commentedFeb 27, 2017
This is supposed to be ready on my end, please review again. |
nicolas-grekas left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
👍
fabpot commentedFeb 28, 2017
Thank you@greg0ire. |
This PR was merged into the 3.3-dev branch.Discussion----------Introduce weak vendors modeDeprecations coming from the vendors are segregated from otherdeprecations. A new mode is introduced, in which deprecations comingfrom the vendors are not taken into account when deciding to exit withan error code.| Q | A| ------------- | ---| Branch? | master| Bug fix? | no| New feature? | no| BC breaks? | no| Deprecations? | no| Tests pass? | yes| License | MIT| Doc PR |symfony/symfony-docs#7453<!--- Bug fixes must be submitted against the lowest branch where they apply (lowest branches are regularly merged to upper ones so they get the fixes too).- Features and deprecations must be submitted against the master branch.- Please fill in this template according to the PR you're about to submit.- Replace this comment by a description of what your PR is solving.-->Sample output :# Weak vendor mode## With both vendors and non-vendor errors```WARNINGS!Tests: 1068, Assertions: 2714, Warnings: 6, Skipped: 15.Remaining deprecation notices (1)some error: 1x 1x in SonataAdminBundleTest::testBuild from Sonata\AdminBundle\TestsRemaining vendor deprecation notices (4)Legacy deprecation notices (48)```Exit code is 1## After fixing non-vendor errors```WARNINGS!Tests: 1068, Assertions: 2714, Warnings: 6, Skipped: 15.Remaining vendor deprecation notices (4)Legacy deprecation notices (48)```Exit code is 0# TODO- [x] fix colorization issues (vendor deprecation notices are always in red)- [x] make the vendor detection more robust- [x] make the vendor dir configurable- [x] ~figure out how to run tests and~ add more of them - [x] test on non-vendor file - [x] test on vendor file- [x] do not change the output of other modesCommits-------61fd043 Introduce weak vendors mode
greg0ire commentedFeb 28, 2017
Made a separate PR for the poor man's error handling :#21795 |
This PR was merged into the master branch.Discussion----------Document the weak_vendors valueSeesymfony/symfony#21539Commits-------abe88c6 Document the weak_vendors value
Uh oh!
There was an error while loading.Please reload this page.
Deprecations coming from the vendors are segregated from other
deprecations. A new mode is introduced, in which deprecations coming
from the vendors are not taken into account when deciding to exit with
an error code.
Sample output :
Weak vendor mode
With both vendors and non-vendor errors
Exit code is 1
After fixing non-vendor errors
Exit code is 0
TODO
figure out how to run tests andadd more of them