-
Notifications
You must be signed in to change notification settings - Fork 56
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
Disallow trigger_error()
, which adds dangerous side-effects to PHP projects
#150
Disallow trigger_error()
, which adds dangerous side-effects to PHP projects
#150
Conversation
trigger_error()
, which adds dangerous side-effects to PHP …trigger_error()
, which adds dangerous side-effects to PHP projects
2c50c60
to
9a1b286
Compare
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'm all for it. The need to temporarily un-deprecate things looks like madness to me (doctrine/persistence#87).
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.
Strong 👎 from me: it is currently the only meaningful way we have to properly communicate those deprecations. Until there is a comparable alternative, we can’t merge this.
I think a better alternative can be researched. I've already started work on tools like Overall, I want |
Once an alternative has been researched and is available, we can rediscuss this. Until then, it’s a firm “no” from me. |
The alternative is Heck, if I'm 10 levels in a stack trace, and a deprecation is caused by two interacting dependencies, that's not useful information anyway. |
There is not enough widespread tooling for dealing with deprecation annotations (yet). I remember discussing this with the doctrine core team a while ago and since then nothing has changed. Back then it was thought that phpstan-deprecation-rules would be able to do this, but it didn’t gain enough traction, so we’re still at the same point. From personal experience dealing with significant BC breaks in ODM 2.0, not everything can be expressed using a deprecation annotation, and often the hoops one would have to go through to accomplish that would be too severe to justify it. |
Not everything has to be expressed, there can be documentation about it, and it would still be better than introducing more side-effects, especially runtime ones. |
There are better ways to communicate BC breaks than upgrade notes. I’m sure there’s a reason this has worked for Symfony for more than 5 years now, whether you agree with it or not. |
Yeah, I disagree with many symfony things, including this one. The fact that symfony is dragged in the discussion is irrelevant anyway, since that's a separate and independent organisation. |
…projects As mentioned in detail in the patch, and experienced first-hand in at least 5 real-world projects so far, plus numerous packages within the doctrine ecosystem itself: > Do not use runtime errors as a way to convey deprecations to users. > Warnings, notices, and errors in general (which aren\'t exceptions) are not usable > in downstream projects, and propagate to global error handlers, causing massive issues > in anything relying on STDOUT, STDERR, aggressive logging, or just expects decent performance > from a dependency. In addition to that, introducing additional runtime effects is a potential > BC break I don't remember when we agreed adding any `@trigger_error()` calls to the codebase, but I remember for sure that I stated (clearly) that `@deprecated` is my preferred way, and even with its own limitations, it still is much simpler to deal with downstream (and from a maintenance PoV).
9a1b286
to
a86edaa
Compare
You may disagree, but having updated multiple applications from one Symfony major to the next, the tooling provided there makes it a lot easier than reading upgrade notes and going code-hunting. If it didn’t work, the team would try something different. |
It already didn't work here.
Marco Pivetta
http://twitter.com/Ocramius
http://ocramius.github.com/
…On Fri, Jan 10, 2020 at 6:39 PM Andreas Braun ***@***.***> wrote:
You may disagree, but having updated multiple applications from one
Symfony major to the next, the tooling provided there makes it a lot easier
than reading upgrade notes and going code-hunting. If it didn’t work, the
team would try something different.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#150?email_source=notifications&email_token=AABFVEB75H5QHSJQWRKW2JTQ5CXDTA5CNFSM4KFKOEV2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEIUVFNY#issuecomment-573133495>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AABFVEHKRTTFW7XYU6VLUNLQ5CXDTANCNFSM4KFKOEVQ>
.
|
What do you mean “it didn’t work here”? If you’re referring to persistence, we chose to revert because we need to coordinate releases if we want to avoid raising errors due to deprecations. Using a different solution (e.g. the phpstan package mentioned earlier) would’ve yielded the same result, regardless of how we deprecated it. The problem wasn’t that we deprecated code, but that we didn’t update our own downstream libraries soon enough. Reverting the deprecations just happened to be the quicker fix than merging and releasing a pull request in ORM. |
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.
@deprecated can't be used for conditional depreciations, eg deprecating setting certain value of argument. Nuff said. People complain about doctrine depreciations because doctrine got sloppy and regularly deprecates stuff while still using 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.
For the same reason @alcaeus and @ostrolucky - it's not entirely @trigger_error
's problem that lead to revert, it's slow adoption throughout our own organization. Also, as I mostly develop in Symfony, these notices are extremely useful as they pop out in our test suite and allowing us to find usage of deprecated stuff than way easier than any upgrade note would. I'd agree with changing course if there'd be any better solution proposed/available, but there's none.
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.
Strong 👍 from me as a former OSS maintainer. ❤️
👎 from me. We need the trigger_error deprecations to guide users to new APIs, The temporary undeprecate in persistence was a learning, that we shouldn't deprecate stuff without having alternatives in place for ourselves.
|
I would be fully on board with forbidding a
Isn't that what the I mean https://3v4l.org/o1E45 Your point about performance still stands though, since apparently deprecations are logged in production in what's probably the most likely configuration of our users' servers right now: https://github.com/symfony/recipes/blob/master/symfony/monolog-bundle/3.1/config/packages/prod/monolog.yaml , but I think if we are more careful about fixing deprecations on our side before propagating them to the rest of the ecosystem, we might be actually fine. I have still no tried phpstan/phpstan-deprecation-rules which I believe is great, but it looks like I'm not the only one ( 702 151 installs vs 28 068 237 installs for the PHPUnit bridge). I know the bridge is not your favorite project, but right now it's fair to say it's one of the biggest channels through which people get their deprecations, the other being the Symfony profiler. |
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 is the best move IMHO. Deprecations aren't errors, they shouldn't affect test suites, and we shouldn't create a sense of urgency to make users run and update stuff.
The fact that we don't have the decent tooling spread enough shouldn't be the excuse for us to settle on a sub-optimal solution.
I honestly had to modify our global error handler to ignore Doctrine's deprecation alerts because they were messing with our logging.
I believe we should provide enough documentation to help people upgrade and not affect runtime.
To elaborate on some of the issues people have mentioned, the first step is to always deprecate things in documentation. This includes marking deprecated members, classes, interfaces, etc. as Once code is deprecated, the question is how users notice these deprecations. Users could go through the upgrade file and then check all their code, but that's a very time-consuming and error-prone process. Tools like The aforementioned way of marking things as I have mentioned listening to deprecations before. One argument that was brought up was that the deprecations create a sense of urgency to upgrade the code. This could be used as an argument against deprecating code in the first place, but not against using One complaint that was mentioned is that these deprecations aren't errors, so they shouldn't be logged at all, shouldn't cause emails to be sent out, and so on. While the name With all that said, I'm closing this PR. We should strive to improve the way we deprecate code and how users are alerted to these deprecations, but this suggestion is a step backwards as it doesn't offer a solution to the problem at hand, it just tries to sweep it under the rug. |
Sorry, but no. First of all, don't go around closing issues because you disagree with them, especially since we have diverging opinions on this thread. Second, the You could say that every The typical upgrade process is:
Goes hand-in-hand with what @lcobucci said: unnecessary/artificial urgency. PHP has the same issue: an upgrade that introduces a deprecation leads to much more added work just because of runtime side-effects that can indeed lead to chaos. The issue is about a fundamental design issue in using You can ask consumers to "change their ways" dozens of times, but how the consumers are configured is completely out of our control (and it should be like that), and introducing global stateful changes (STDERR/STDOUT/error handling) where there previously weren't is a clear BC break. |
A significant part of the Doctrine Core team disagrees with this PR, which is why I closed it. If you'd rather keep it open, that's perfectly fine. Maybe I didn't word it clearly enough in my comment above, but the work isn't because we use But if we go and deprecate code (which we definitely should) for removal in future versions, we need to ensure that users have a fair chance of reacting to those deprecations. I've said it before, and I'll say it again: until we have a proper solution in place to deal with deprecations, we can't merge this. The paragraph above shows that we have more pressing issues than this, and I would suggest we start focussing our energy on that. |
It wasn't closed because @alcaeus disagrees with it. Most members disagree with this proposal so won't be merged and that's it.
Source? What I saw was that patches for supporting new symfony releases were minimal. It was mess in doctrine ecosystem causing problems, eg. supporting new doctrine persistence release. Also not seeing how it's relevant to trigger_error, since we don't opt-in into collecting these. They could actually help us if we did opt into them.
You are arguing against upgrade path, am I getting it correctly?
BC break is whatever we define is. Renaming private function is also technically BC break, since users can be accessing it through reflection. But we don't care about such usage. Similarly, we don't consider "bc break" something for which users have to hook into global error handler. This is opt in behaviour and these users want test suite to break if they use deprecated functionality. I would argue we are breaking their CI setup if we stop using trigger_error, because it will no longer alert them when they do use deprecated functionality, hence their setup no longer working as intended.
So PHP disagrees with your stand as well. Runtime deprecation notices (which are easy to enable/disable) are very effective in letting consumers (who are interested into that) know that they need to update something in order for it to work in future php versions. Otherwise people would have to do massive work when doing major upgrades. I don't see why doctrine should be different than rest of the PHP ecosystem. |
How do you feel about symfony/symfony#35526? |
Use `global $deprecations[] = 'the deprecation';`. It's still a
side-effect, but at least it's not a mess that has hooks into it, and most
certainly not hooks that interact with your current runtime.
If you really must log these, you can then add a shutdown handler, which
can indeed operate in a procedural/unsafe way.
…On Wed, Feb 5, 2020, 12:46 Andreas Möller ***@***.***> wrote:
How do you feel about symfony/symfony#35526
<symfony/symfony#35526>?
—
You are receiving this because you modified the open/close state.
Reply to this email directly, view it on GitHub
<#150?email_source=notifications&email_token=AABFVEGH65GQVRGLWBRCGJTRBKRK5A5CNFSM4KFKOEV2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEK3EMSI#issuecomment-582370889>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AABFVEATYK44URL2VUPOXX3RBKRK5ANCNFSM4KFKOEVQ>
.
|
As mentioned in detail in the patch, and experienced first-hand in at least 5 real-world projects
so far, plus numerous packages within the doctrine ecosystem itself:
I don't remember when we agreed adding any
@trigger_error()
calls to the codebase, but I rememberfor sure that I stated (clearly) that
@deprecated
is my preferred way, and even with its own limitations,it still is much simpler to deal with downstream (and from a maintenance PoV).