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

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

Merged
nicolas-grekas merged 1 commit intosymfony:2.7fromgreg0ire:defer_exit
Feb 11, 2018
Merged

Conversation

@greg0ire
Copy link
Contributor

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:

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

QA
Branch?2.7
Bug fix?yes
New feature?no
BC breaks?no
Deprecations?no
Tests pass?yes
LicenseMIT

linaori reacted with thumbs up emoji
@greg0ire
Copy link
ContributorAuthor

@alcaeus please review


if ('weak' !==$mode && ($deprecations['unsilenced'] ||$deprecations['remaining'] ||$deprecations['other'])) {
exit(1);
register_shutdown_function(function () {
Copy link
Member

@nicolas-grekasnicolas-grekasFeb 2, 2018
edited
Loading

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 :) )

Copy link
ContributorAuthor

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.

Copy link
Member

@nicolas-grekasnicolas-grekasFeb 2, 2018
edited
Loading

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 :)

greg0ire reacted with thumbs up emoji
Copy link
ContributorAuthor

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

Copy link
ContributorAuthor

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

@chalasrchalasr added this to the2.7 milestoneFeb 2, 2018
@greg0ire
Copy link
ContributorAuthor

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

@greg0iregreg0ireFeb 3, 2018
edited
Loading

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.

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

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

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

Copy link
ContributorAuthor

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) {

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?

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

done

@alcaeus
Copy link
Contributor

the second commit feels more like a feature than a bugfix to me

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.

Copy link
Member

@nicolas-grekasnicolas-grekas left a comment
edited
Loading

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

greg0ire commentedFeb 4, 2018
edited
Loading

Correct, but let me try to test it on 5.4 to be 100% sure.

@greg0ire
Copy link
ContributorAuthor

greg0ire commentedFeb 4, 2018
edited
Loading

Don't merge, I get this, which seems to be a bug since I used the same version as in Travis:

Fatal error: Class 'PHPUnit_Util_ErrorHandler' not found in /tmp/sf/src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php on line 54

Then, with a var_dump($msg) on the offending line, this:

"Use of undefined constant ARRAY_FILTER_USE_KEY - assumed 'ARRAY_FILTER_USE_KEY'"

This can't work for php < 5.6

@greg0ire
Copy link
ContributorAuthor

greg0ire commentedFeb 4, 2018
edited
Loading

I fixed it however I could, it should be good to merge now (although Travis is still red)

@greg0ire
Copy link
ContributorAuthor

Why exactly do we have thoseCount indices, BTW? I suppose the answer is performance, somehow?

@greg0ire
Copy link
ContributorAuthor

Tested withdocker run -it -v $PWD:/tmp/sf squallcx/docker-php54-apache /bin/sh

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";

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

Thank you@greg0ire.

@nicolas-grekasnicolas-grekas merged commit97370a3 intosymfony:2.7Feb 11, 2018
nicolas-grekas added a commit that referenced this pull requestFeb 11, 2018
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
@greg0iregreg0ire deleted the defer_exit branchFebruary 11, 2018 16:17
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@nicolas-grekasnicolas-grekasnicolas-grekas approved these changes

Assignees

No one assigned

Projects

None yet

Milestone

2.7

Development

Successfully merging this pull request may close these issues.

5 participants

@greg0ire@alcaeus@nicolas-grekas@chalasr@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp