Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[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

Merged
nicolas-grekas merged 1 commit intosymfony:2.7fromreecefowell:2.7
Jun 10, 2015
Merged

Conversation

reecefowell
Copy link
Contributor

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       | MIT

Fixes#14899

http://cdn.meme.am/instances2/500x/125359.jpg

@perk11
Copy link

👍 had numerous deprecated warnings after upgrading to 2.7 and this PR solved all of them.

@xabbuh
Copy link
Member

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'serror_reporting level, but I'd rather update your code.

@xabbuhxabbuh closed thisJun 7, 2015
@nicolas-grekas
Copy link
Member

This PR may be a good idea in fact don't you think?

@elnur
Copy link
Contributor

The most profound PR I've ever seen. A must merge. 👍

@xabbuh
Copy link
Member

@nicolas-grekas Not sure if I understand. Which issue would this change actually solve?

@nicolas-grekas
Copy link
Member

It switches deprecation notices from opt-out to opt-in

@xabbuh
Copy link
Member

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
Copy link
ContributorAuthor

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
Copy link
Member

Still thinking about it, I really like the idea.
Upgrading to 3.0 is also an opt in, the upgrade path is clear.

I'm 👍
Reopening to see what other @symfony/deciders think

@nicolas-grekas
Copy link
Member

@reecefowell can you please enhance the commit message?

@@ -224,7 +224,7 @@ class JsonSerializableObject implements \JsonSerializable
{
public function jsonSerialize()
{
trigger_error('This error is expected', E_USER_WARNING);
@trigger_error('This error is expected', E_USER_WARNING);

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
Copy link
Member

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
Copy link
Member

nicolas-grekas commentedJun 7, 2015 via email

Yes, the debug handler ignores silencing for deprecations. The overhead isnot significant at all.

@fabpot
Copy link
Member

ping @symfony/deciders

If we agree on this one, I'd like to merge ASAP for at least two reasons:

  • I want to release 2.7.1 ASAP
  • Maintaining such a large patch is going to be difficult over time.

@Tobion
Copy link
Contributor

So this only changes that the deprecation warnings are ignored in production, or?

@nicolas-grekas
Copy link
Member

Yes, by default

@@ -170,7 +170,7 @@ public function testDeprecatedSuper($class, $super, $type)
{
set_error_handler('var_dump', 0);
$e = error_reporting(0);
trigger_error('', E_USER_DEPRECATED);
@trigger_error('', E_USER_DEPRECATED);
Copy link
ContributorAuthor

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?

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
Copy link
Contributor

So how would I turn on deprecation notices now?

@nicolas-grekas
Copy link
Member

By adding a user land error handler, like the one provided by e.g. the debug component

@reecefowellreecefowellforce-pushed the2.7 branch 2 times, most recently fromeb261d4 to00ac865CompareJune 8, 2015 09:26
@reecefowell
Copy link
ContributorAuthor

Comments addressed in code, also tests are now passing. Somehow though I seem to have broken fabbot.io.

The patch just gave me this

curl http://fabbot.io/patch/symfony/symfony/14900/eb261d45b038f9af47a92b4e6b602bcf8a853816/cs.diff | patch -p0  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current                                 Dload  Upload   Total   Spent    Left  Speed100  8717  100  8717    0     0  20591      0 --:--:-- --:--:-- --:--:-- 20607patch: **** Only garbage was found in the patch input.

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
Copy link
Member

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
Copy link
Member

Ready to be merged?

@phansys
Copy link
Contributor

Nice! Thanks for the clarification@nicolas-grekas.

@Tobion
Copy link
Contributor

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
Copy link
Member

@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.
If we think the deprecations should be opt-in, as would be migrating 3.0, then this PR is the right one.
Nobody but me voted here. Please do @symfony/deciders

@nicolas-grekas
Copy link
Member

@reecefowell please rebase

@lsmith77
Copy link
Contributor

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@trigger_error().

@nicolas-grekas
Copy link
Member

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.
Thus this raw-bare-metal-php implementation that may look hacky, but is just the right implementation for our needs. At least that's my humble opinion :)

@@ -5,7 +5,7 @@ Global
------

* `E_USER_DEPRECATED` warnings -
`trigger_error('... is deprecated ...', E_USER_DEPRECATED)` -
`@trigger_error('... is deprecated ...', E_USER_DEPRECATED)` -
are now triggered when using all deprecated functionality.
To avoid filling up error logs, you may need to add

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
Copy link
Member

I'm going to merge this today if nobody vote otherwise.

@jakzal
Copy link
Contributor

👍 as I see people struggling with deprecation messages, especially in cli. However, we should provide clear instructions on how to enable them.

@stof
Copy link
Member

👍

It also means we are much less intrusive for other libraries relying on Symfony 2.x

@matthias-chlechowitz

👍

1 similar comment
@aitboudad
Copy link
Contributor

👍

@xabbuh
Copy link
Member

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.

@nicolas-grekasnicolas-grekas merged commit73bbaa6 intosymfony:2.7Jun 10, 2015
nicolas-grekas added a commit that referenced this pull requestJun 10, 2015
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#14899![http://cdn.meme.am/instances2/500x/125359.jpg](http://cdn.meme.am/instances2/500x/125359.jpg)Commits-------73bbaa6 Silence invasive deprecation warnings, opt-in for warnings
@nicolas-grekas
Copy link
Member

Thank you@reecefowell

@nicolas-grekas
Copy link
Member

@xabbuh we still have to work on better deprecations reporting.
But at least, we can do it quietly now, without hurting users.

@reecefowell
Copy link
ContributorAuthor

Thanks everyone :)

@craue
Copy link
Contributor

Are bundle developers encouraged to do this as well?

@nicolas-grekas
Copy link
Member

@craue I'd say yes!

@reecefowellreecefowell deleted the 2.7 branchJune 10, 2015 16:46
@mmoreram
Copy link
Contributor

👍 Good move :)

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers
No reviews
Assignees
No one assigned
Labels
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

17 participants
@reecefowell@perk11@xabbuh@nicolas-grekas@elnur@stof@fabpot@Tobion@linaori@weaverryan@phansys@lsmith77@jakzal@matthias-chlechowitz@aitboudad@craue@mmoreram

[8]ページ先頭

©2009-2025 Movatter.jp