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

added catching of php7 fatal exceptions in application #20110#20111

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
bozerkins wants to merge5 commits intosymfony:2.8frombozerkins:2.8-fix-exception-catching-in-application-php7
Closed

added catching of php7 fatal exceptions in application #20110#20111

bozerkins wants to merge5 commits intosymfony:2.8frombozerkins:2.8-fix-exception-catching-in-application-php7

Conversation

@bozerkins
Copy link

@bozerkinsbozerkins commentedSep 30, 2016
edited by nicolas-grekas
Loading

QA
Branch?2.8 2.7
Bug fix?yes
New feature?no
BC breaks?no
Deprecations?no
Tests pass?yes
Fixed tickets#20110
LicenseMIT
Doc PR- - -
  • added new private method to application, which would process the exception and return the exit code / throw it
  • added another catch into command run method, which would ensure that under PHP7 all exceptions are being catched as well

- added new private method to application, which would process the exception and return the exit code / throw it- added another catch into command run method, which would ensure that under PHP7 all exceptions are being catched as well
@nicolas-grekas
Copy link
Member

Doesn't#19813 fix the issue?

@bozerkins
Copy link
Author

bozerkins commentedSep 30, 2016
edited
Loading

partially.

when no dispatcher is present - the fatal exceptions will not be catched anyways.

https://github.com/fonsecas72/symfony/blob/65e53ece4c867dc0447d3a215fdda8170e163745/src/Symfony/Component/Console/Application.php#L845

though i liked the approach. i could adjust this PR so it creates a FatalThrowableError object and works with that.

this way we'd avoid creating another method


if ($outputinstanceof ConsoleOutputInterface) {
$this->renderException($e,$output->getErrorOutput());
}else {
Copy link
Contributor

Choose a reason for hiding this comment

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

The phpdoc ofrenderException with@param \Exception $e is not correct anymore and needs to be updated too.

Copy link
Author

Choose a reason for hiding this comment

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

done some changes. took the approach of#19813

now should be just fine

- implemented compatibilit with PHP7 fatal errors- using FatalThrowableError for BC with PHP5
if ($exception) {
if (!$this->catchExceptions) {
throw$e;
throw$exception;
Copy link
Member

@nicolas-grekasnicolas-grekasOct 3, 2016
edited
Loading

Choose a reason for hiding this comment

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

$e should be thrown here, not$exception (no wrapper)

Copy link
Author

Choose a reason for hiding this comment

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

you mean FatalThrowableError should not be here at all?

Choose a reason for hiding this comment

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

yes, when rethrowing, the original exception should be thrown

@bozerkins
Copy link
Author

done. now the changes have become as simple and straight forward as possible

@nicolas-grekas
Copy link
Member

nicolas-grekas commentedOct 5, 2016
edited
Loading

Let's change the type hint (doc comment) on the renderException method also (Throwable instead of Exception), that would be consistent with what is done here

@nicolas-grekas
Copy link
Member

nicolas-grekas commentedOct 6, 2016
edited
Loading

Here is the patch I propose to finish this PR:

--- a/src/Symfony/Component/Console/Application.php+++ b/src/Symfony/Component/Console/Application.php@@ -102,8 +102,6 @@ class Application      * @param OutputInterface $output An Output instance      *      * @return int 0 if everything went fine, or an error code-     *-     * @throws \Exception When doRun returns Exception      */     public function run(InputInterface $input = null, OutputInterface $output = null)     {@@ -634,7 +632,7 @@ class Application     /**      * Renders a caught exception.      *-     * @param \Exception      $e      An exception instance+     * @param \Throwable      $e      An exception instance      * @param OutputInterface $output An OutputInterface instance      */     public function renderException($e, $output)@@ -831,8 +829,6 @@ class Application      * @param OutputInterface $output  An Output instance      *      * @return int 0 if everything went fine, or an error code-     *-     * @throws \Exception when the command being run threw an exception      */     protected function doRunCommand(Command $command, InputInterface $input, OutputInterface $output)     {

Note also that it should be merged on 2.7!

@fabpot
Copy link
Member

@bozerkins Can you take@nicolas-grekas comments into account?

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
@fabpotfabpot closed thisDec 5, 2016
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@nicolas-grekasnicolas-grekasnicolas-grekas left review comments

+1 more reviewer

@TobionTobionTobion left review comments

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

5 participants

@bozerkins@nicolas-grekas@fabpot@Tobion@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp