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

[Console] fixed PHP7 Errors are now handled and converted to Exceptions#19813

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

Closed
fonsecas72 wants to merge2 commits intosymfony:2.7fromfonsecas72:ticket_18484

Conversation

@fonsecas72
Copy link

QA
Branch?2.7
Bug fix?yes
New feature?no
BC breaks?no
Deprecations?no
Tests pass?yes
Fixed tickets#18484
LicenseMIT
Doc PR

TomasVotruba reacted with thumbs up emoji
@HeahDude
Copy link
Contributor

ping@romqin@skigun :)

@TomasVotruba
Copy link
Contributor

Test would be great for this.


$event =newConsoleTerminateEvent($command,$input,$output,$e->getCode());
$this->dispatcher->dispatch(ConsoleEvents::TERMINATE,$event);

Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't we be throwing the original throwable here. This is a BC break?

Choose a reason for hiding this comment

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

I agree

Copy link
Author

@fonsecas72fonsecas72Sep 7, 2016
edited
Loading

Choose a reason for hiding this comment

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

What does it mean?
That I should delete the$e = new FatalThrowableError($e); line?

Choose a reason for hiding this comment

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

I propose this:

try {$e =null;$exitCode =$command->run($input,$output);}catch (\Exception$x) {$e =$x;}catch (\Throwable$x) {$e =newFatalThrowableError($x);}if (null !==$e) {$event =newConsoleExceptionEvent($command,$input,$output,$e,$e->getCode());$this->dispatcher->dispatch(ConsoleEvents::EXCEPTION,$event);$e =$event->getException();$event =newConsoleTerminateEvent($command,$input,$output,$e->getCode());$this->dispatcher->dispatch(ConsoleEvents::TERMINATE,$event);throw$x;}

Copy link
Contributor

Choose a reason for hiding this comment

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

I think it would be better to just add another function and call that at the end of each try catch?

Copy link
Contributor

Choose a reason for hiding this comment

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

try {    $exitCode = $command->run($input, $output);} catch (\Exception $e) {    $this->someFuntion($e);    throw $e;} catch (\Throwable $x) {    $this->someFuntion(new FatalThrowableError($e));    throw $e;}

Copy link
Author

Choose a reason for hiding this comment

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

I will go with whatever solution you find better /cc@nicolas-grekas :)

Choose a reason for hiding this comment

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

It's a pure matter of coding style, I don't care :)

@nicolas-grekas
Copy link
Member

Looks like this is untested, can you add a test case please?
The composer.json file misses a requirement for the debug component now (~2.7).

@fonsecas72
Copy link
Author

@nicolas-grekas it's done I believe, thanks
Is there anything else I can do to improve this?

@fonsecas72fonsecas72force-pushed theticket_18484 branch 2 times, most recently from999beb4 toa5250fdCompareSeptember 6, 2016 12:53
"require": {
"php":">=5.3.9"
"php":">=5.3.9",
"symfony/debug":"~2.7,>=2.7.14"

Choose a reason for hiding this comment

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

Should be ~2.7,>=2.7.2

@fonsecas72fonsecas72force-pushed theticket_18484 branch 3 times, most recently from8e1b521 to93ae8c6CompareSeptember 7, 2016 11:59
"require": {
"php":">=5.3.9"
"php":">=5.3.9",
"symfony/debug":"~2.7,>=2.7.2"
Copy link
Contributor

Choose a reason for hiding this comment

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

^2.7.2?

Copy link
Contributor

Choose a reason for hiding this comment

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

also, what about 3.x?

Choose a reason for hiding this comment

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

we don't use^ yet
we'll add 3.x when merging into 2.8 (the only branch that opens to 3.x)

Copy link
Contributor

Choose a reason for hiding this comment

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

ok :)

@fonsecas72
Copy link
Author

fonsecas72 commentedSep 7, 2016
edited
Loading

@nicolas-grekas the original exception is being re-throw and tests are updated/fixed now


/**
* @expectedException \LogicException
* @expectedException \RuntimeException

Choose a reason for hiding this comment

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

So my bad, this can't change, that would be a bc break.
I propose to tweak the implementation like this, so that the original exception is preserved, except when a listener decides to alter it:

try {$e =null;$exitCode =$command->run($input,$output);            }catch (\Exception$x) {$e =$x;            }catch (\Throwable$x) {$e =newFatalThrowableError($x);            }if (null !==$e) {$event =newConsoleExceptionEvent($command,$input,$output,$e,$e->getCode());$this->dispatcher->dispatch(ConsoleEvents::EXCEPTION,$event);if ($e !==$event->getException()) {$x =$e =$event->getException();                }$event =newConsoleTerminateEvent($command,$input,$output,$e->getCode());$this->dispatcher->dispatch(ConsoleEvents::TERMINATE,$event);throw$x;            }

Copy link
Author

@fonsecas72fonsecas72Sep 7, 2016
edited
Loading

Choose a reason for hiding this comment

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

oh now I get it! I've added a little test for that too. I hope everything is ok now :)

@nicolas-grekas
Copy link
Member

👍

@fabpot
Copy link
Member

Thank you@fonsecas72.

fabpot added a commit that referenced this pull requestSep 8, 2016
…to Exceptions (fonsecas72)This PR was squashed before being merged into the 2.7 branch (closes#19813).Discussion----------[Console] fixed PHP7 Errors are now handled and converted to Exceptions| Q             | A| ------------- | ---| Branch?       | 2.7| Bug fix?      | yes| New feature?  | no| BC breaks?    | no| Deprecations? | no| Tests pass?   | yes| Fixed tickets |#18484| License       | MIT| Doc PR        |Commits-------d3c613b [Console] fixed PHP7 Errors are now handled and converted to Exceptions
@fabpotfabpot closed thisSep 8, 2016
@fonsecas72
Copy link
Author

@fonsecas72fonsecas72 deleted the ticket_18484 branchSeptember 8, 2016 15:38
@TomasVotruba
Copy link
Contributor

@fonsecas72 Glad to help :)

@GrahamCampbellGrahamCampbell mentioned this pull requestSep 13, 2016
This was referencedOct 3, 2016
fabpot added a commit that referenced this pull requestDec 5, 2016
…adus)This PR was squashed before being merged into the 2.7 branch (closes#20736).Discussion----------[Console] fixed PHP7 Errors when not using Dispatcher| Q             | A| ------------- | ---| Branch?       | 2.7| Bug fix?      | yes| New feature?  | no| BC breaks?    | no| Deprecations? | no| Tests pass?   | yes| Fixed tickets |#17257,#20110,#20111| License       | MIT| Doc PR        | n/aOriginal fix,#19813, works only when there is event dispatcher available.This PR fix the issue also for scenario without event dispatcher.Closes#20110 issue and#20111 PR connected to it.Closing#17257 , as everywhere the error is converted to exception and it should be handledCommits-------899fa79 [Console] fixed PHP7 Errors when not using Dispatcher
@ro0NLro0NL mentioned this pull requestNov 13, 2017
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

7 participants

@fonsecas72@HeahDude@TomasVotruba@nicolas-grekas@fabpot@GrahamCampbell@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp