Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.7k
[RFC] Fixing Deprecation Warnings#14900
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
perk11 commentedJun 7, 2015
👍 had numerous deprecated warnings after upgrading to 2.7 and this PR solved all of them. |
xabbuh commentedJun 7, 2015
The deprecation warnings are triggered intentionally to let you know what you need to change in your code to be forward compatible with Symfony 3.0. Youcould silence them by changing your project's |
nicolas-grekas commentedJun 7, 2015
This PR may be a good idea in fact don't you think? |
elnur commentedJun 7, 2015
The most profound PR I've ever seen. A must merge. 👍 |
xabbuh commentedJun 7, 2015
@nicolas-grekas Not sure if I understand. Which issue would this change actually solve? |
nicolas-grekas commentedJun 7, 2015
It switches deprecation notices from opt-out to opt-in |
xabbuh commentedJun 7, 2015
Yeah, but is that really a good idea? I bet that many people then will never know about this and that they will be surprised when their apps break on Symfony 3.0. Not sure if that's a good experience either. |
reecefowell commentedJun 7, 2015
I think it is a good idea.@deprecated tags are sufficient, but calling trigger_error() is very shouty. Googling most of the deprecated errors that come out result in most cases with the people discussing end suggesting and / or agreeing that muting E_DEPRECATED in php.ini is the best solution. If the intent is to get people to prepare for 3.0 then, well people aren't. Instead they are just muting the warnings. Further more, for upgraders, seeing the messages for the first time, diagnosing / solving them the correct way is very difficult as google has little to offer in the way of answers. Perhaps some of the deprecated calls don't actually have future ready implementations in place yet. I believe this was the case with the Form components OptionResolverInterface, which my IDE informs me was deprecated in (I think it was) 2.5 or so, but no alternative was provided until something like 2.6 (with OptionResolver). |
nicolas-grekas commentedJun 7, 2015
Still thinking about it, I really like the idea. I'm 👍 |
nicolas-grekas commentedJun 7, 2015
@reecefowell can you please enhance the commit message? |
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.
This one is not a deprecation, please revert and ensure that you silence only deprecations
stof commentedJun 7, 2015
@nicolas-grekas are these deprecation warnings still reported in the logs after being muted or no ? And does the silencing add some overhead or no ? |
nicolas-grekas commentedJun 7, 2015 via email
Yes, the debug handler ignores silencing for deprecations. The overhead isnot significant at all. |
fabpot commentedJun 7, 2015
ping @symfony/deciders If we agree on this one, I'd like to merge ASAP for at least two reasons:
|
Tobion commentedJun 7, 2015
So this only changes that the deprecation warnings are ignored in production, or? |
nicolas-grekas commentedJun 8, 2015
Yes, by default |
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.
Why is this even here? It doesn't have a message. Presumably the intention is to pass to the $e var to trigger_error?
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.
It's a trick to reset the state of error_get_last() a few lines below. Silencing should be reverted here, as it's already done on line 172.
linaori commentedJun 8, 2015
So how would I turn on deprecation notices now? |
nicolas-grekas commentedJun 8, 2015
By adding a user land error handler, like the one provided by e.g. the debug component |
eb261d4 to00ac865Comparereecefowell commentedJun 8, 2015
Comments addressed in code, also tests are now passing. Somehow though I seem to have broken fabbot.io. The patch just gave me this So I applied the changes manually, but I guess maybe because I pushed another fix while fabbot.io was still running it broke it this time around. Fabbot.io was talking about code I never touched though. So I guess those problems were already there. Apparently the patch only contains garbage.... 😕 Other than that. Good to go. |
weaverryan commentedJun 8, 2015
To summarize a few questions people had (that I also had): A) Do you still get deprecated warnings in the web debug toolbar? YES B) Do deprecation warnings still show up in the logs? NO Does this have any other side effects? If there are no other side effects, I'm +1. We can add something to the "how to get rid of deprecation warnings" section of the docs to show people how to hook up an error handler to log the deprecation warnings. |
fabpot commentedJun 9, 2015
Ready to be merged? |
phansys commentedJun 9, 2015
Nice! Thanks for the clarification@nicolas-grekas. |
Tobion commentedJun 9, 2015
Would it not be better to change the production error handler instead to not log by default if that is what we want? Triggering deprecations and at the same time silence them seems like a hack. |
nicolas-grekas commentedJun 10, 2015
@Tobion this PR solves a real issue/pain users experiment with 2.7.: they must opt-out from deprecation notices. If we think this is required then we should not merge this PR. |
nicolas-grekas commentedJun 10, 2015
@reecefowell please rebase |
lsmith77 commentedJun 10, 2015
I agree that this should have been opt-in rather than opt-out. I do not know if there is a more elegant approach as I agree with@Tobion it seems hacky to use |
nicolas-grekas commentedJun 10, 2015
I understand how you can see this as a hack. There is an other consideration that makes me think this is really the best: performance. We could wrap the implementation of triggering "opt-in deprecation notices" behind some more semantic interface. But that would add overhead to something that needs to be as fast as possible. This is not a micro-optim when this can be called thousands of times. |
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.
This sentence looks wrong now, the UPGRADE needs an update
fabpot commentedJun 10, 2015
I'm going to merge this today if nobody vote otherwise. |
jakzal commentedJun 10, 2015
👍 as I see people struggling with deprecation messages, especially in cli. However, we should provide clear instructions on how to enable them. |
stof commentedJun 10, 2015
👍 It also means we are much less intrusive for other libraries relying on Symfony 2.x |
matthias-chlechowitz commentedJun 10, 2015
👍 |
1 similar comment
aitboudad commentedJun 10, 2015
👍 |
xabbuh commentedJun 10, 2015
I am still not fully convinced. How would people now see the stack trace for a triggered deprecation if it is not contained in the logs? The debug toolbar doesn't provide one. |
This PR was merged into the 2.7 branch.Discussion----------[RFC] Fixing Deprecation WarningsThis PR address an issue that causes Symfony to vomit E_DEPRECATED warnings everywhere.```markdown| Q | A| ------------- | ---| Bug fix? | yes| New feature? | no| BC breaks? | no| Deprecations? | no| Tests pass? | yes| Fixed tickets |#14899| License | MIT```Fixes#14899Commits-------73bbaa6 Silence invasive deprecation warnings, opt-in for warnings
nicolas-grekas commentedJun 10, 2015
Thank you@reecefowell |
nicolas-grekas commentedJun 10, 2015
@xabbuh we still have to work on better deprecations reporting. |
reecefowell commentedJun 10, 2015
Thanks everyone :) |
craue commentedJun 10, 2015
Are bundle developers encouraged to do this as well? |
nicolas-grekas commentedJun 10, 2015
@craue I'd say yes! |
mmoreram commentedJun 11, 2015
👍 Good move :) |
This PR address an issue that causes Symfony to vomit E_DEPRECATED warnings everywhere.
| Q | A| ------------- | ---| Bug fix? | yes| New feature? | no| BC breaks? | no| Deprecations? | no| Tests pass? | yes| Fixed tickets |#14899| License | MITFixes#14899