Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.7k
Exit as late as possible#26012
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
Exit as late as possible#26012
Uh oh!
There was an error while loading.Please reload this page.
Conversation
greg0ire commentedFeb 1, 2018
@alcaeus please review |
| if ('weak' !==$mode && ($deprecations['unsilenced'] ||$deprecations['remaining'] ||$deprecations['other'])) { | ||
| exit(1); | ||
| register_shutdown_function(function () { |
nicolas-grekasFeb 2, 2018 • 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.
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.
what would be even better would be to defer the whole closure, so that deprecations triggered at shutdown time are also caught (and add a related test of course :) )
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 downside being that if a shutdown function usesexit and the whole closure is deferred too, then you won't get any deprecations. But I think catching shutdown time deprecations might outweight this, what do you think? If we want to go crazy, we may even reset the state after the first, non deferred display and if any deprecations are caught while shutting down, then display them in the deferred closure.
nicolas-grekasFeb 2, 2018 • 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.
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.
as you want, both are fine to me :)
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'll see what I can manage
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.
Ended up "going crazy", tell me what you think
greg0ire commentedFeb 3, 2018
Best reviewed whenignoring whitespace @nicolas-grekas the second commit feels more like a feature than a bugfix to me. Would you be ok with moving it to a separate PR? |
| 1x: root deprecation | ||
| Deprecations during shutdown |
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.
Please tell me if you want more emphasis here and how it should look like (ascii underline with= signs, maybe?), and if I should also add some header for the previous section.
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 more than existing titles, so as is LGTM
| } | ||
| register_shutdown_function(function ()use (&$deprecations,$isFailing,$displayDeprecations) { | ||
| if (array_sum(array_filter($deprecations,function ($key) { |
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 calls for a data structure refactoring
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.
let's do a code-style fix for now :) the "if" should be on one line
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" :P
| echo"Deprecations during shutdown\n"; | ||
| } | ||
| $displayDeprecations($deprecations); | ||
| if ($isFailing) { |
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.
if there are shutdown-time deprecations, shouldn't this fail also?
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.
done
alcaeus commentedFeb 4, 2018
TBH, I'd still consider it a bugfix: the original bug was that any existing deprecations cause other shutdown handlers to be ignored. This is fixed in your first commit. Fixing that bug exposes another bug, namely that any deprecations happening in other shutdown handlers don't reported. This is fixed in your second commit. |
07fe27a tod0e85e5Compare
nicolas-grekas left a comment• 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.
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.
(failures should be fixed once merged up to master, isn't it?)
greg0ire commentedFeb 4, 2018 • 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.
Correct, but let me try to test it on 5.4 to be 100% sure. |
greg0ire commentedFeb 4, 2018 • 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.
Don't merge, I get this, which seems to be a bug since I used the same version as in Travis:
Then, with a
This can't work for php < 5.6 |
greg0ire commentedFeb 4, 2018 • 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 fixed it however I could, it should be good to merge now (although Travis is still red) |
greg0ire commentedFeb 4, 2018
Why exactly do we have those |
greg0ire commentedFeb 4, 2018
Tested with |
| register_shutdown_function(function ()use (&$deprecations,$isFailing,$displayDeprecations,$mode) { | ||
| foreach ($deprecationsas$group =>$arrayOrInt) { | ||
| if (is_int($arrayOrInt) &&$arrayOrInt >0 ||is_array($arrayOrInt) &&count($arrayOrInt) >0) { | ||
| echo"Deprecations during shutdown\n"; |
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.
Small tweak: s/Deprecations during shutdown/Shutdown-time deprecations:/
People might want to register other shutdown functions that should beable to control the exit code themselves, without the deprecation errorhandler taking over. The php manual says:> If you call exit() within one registered shutdown function, processing> will stop completely and no other registered shutdown functions will be> called.Seehttps://secure.php.net/manual/en/function.register-shutdown-function.php
nicolas-grekas commentedFeb 11, 2018
Thank you@greg0ire. |
This PR was merged into the 2.7 branch.Discussion----------Exit as late as possiblePeople might want to register other shutdown functions that should beable to control the exit code themselves, without the deprecation errorhandler taking over. The php manual says:> If you call exit() within one registered shutdown function, processing> will stop completely and no other registered shutdown functions will be> called.Seehttps://secure.php.net/manual/en/function.register-shutdown-function.php| Q | A| ------------- | ---| Branch? | 2.7| Bug fix? | yes| New feature? | no| BC breaks? | no| Deprecations? | no| Tests pass? | yes| License | MIT<!--- 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.- Replace this comment by a description of what your PR is solving.-->Commits-------97370a3 [Bridge\PhpUnit] Exit as late as possible
People might want to register other shutdown functions that should be
able to control the exit code themselves, without the deprecation error
handler taking over. The php manual says:
Seehttps://secure.php.net/manual/en/function.register-shutdown-function.php