Skip to content

[2.7] Fixed flatten exception recursion with errors #17052

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

Closed
wants to merge 4 commits into from
Closed

[2.7] Fixed flatten exception recursion with errors #17052

wants to merge 4 commits into from

Conversation

GrahamCampbell
Copy link
Contributor

Q A
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets N/A
License MIT
Doc PR N/A

Consider the following code:

$error = new ParseError();

$exception = new RuntimeException($error->getMessage(), $error->getCode(), $error);

$flat = new Symfony\Component\Debug\Exception\FlattenException($exception);

Without this fix, that code is broken.

You'll end up with something like this:

FatalThrowableError in FlattenException.php line 76:
Type error: Argument 1 passed to Symfony\Component\Debug\Exception\FlattenException::create() must be an instance of Exception, instance of ParseError given

I came across this error issue in laravel/framework#11329.

@stof
Copy link
Member

stof commented Dec 17, 2015

this is not good, as it looses the debugging info.It might be better to wrap it in a FatalThrowableError to be able to continue the flattening

@GrahamCampbell
Copy link
Contributor Author

I'm fine with that if you want me to make that change. I just thought you'd want to separate that behaviour from that class, so I went with skipping.

@GrahamCampbell
Copy link
Contributor Author

How does this look then?

@nicolas-grekas
Copy link
Member

👍
And if you manage to add a test case I would be +2 :)

@GrahamCampbell
Copy link
Contributor Author

I'll add a couple of tests in a few hours.

@nicolas-grekas
Copy link
Member

Status: needs work

@GrahamCampbell
Copy link
Contributor Author

Sorry, I'll get to this soon. ;)

@GrahamCampbell
Copy link
Contributor Author

Ping @nicolas-grekas. Not sure what's going on with travis. Looks like it couldn't be arsed to run the tests for some reason?

@GrahamCampbell
Copy link
Contributor Author

Yeh, PHP 5.4 and 5.5 are running no tests for some reason. :/

@GrahamCampbell
Copy link
Contributor Author

This travis issue is affecting the entire code base. For example, one of your PRs didn't get the tests run: #17104.

@nicolas-grekas
Copy link
Member

5.4 and 5.5 are skipped for PRs so that we get more slots on travis

@GrahamCampbell
Copy link
Contributor Author

Ah, right, so it was intentional. That makes sense. I was just worried that they were getting silently skipped. ;)

@GrahamCampbell
Copy link
Contributor Author

They still waste about 50 seconds of time though each. :(

@nicolas-grekas
Copy link
Member

Yep... I found no way to be quicker, the slow part is apt-get, which can't be skipped AFAIK

@GrahamCampbell
Copy link
Contributor Author

Test passing now btw. ;)

@nicolas-grekas
Copy link
Member

👍

@GrahamCampbell
Copy link
Contributor Author

Is this good to merge then? I'm just concious that new symfony releases normally happen around a month after the previous ones, and I'd quite like to have this fix included in the next set of releases.

BTW, Happy Christmas everyone. 🎄

@fabpot
Copy link
Member

fabpot commented Dec 26, 2015

Thank you @GrahamCampbell.

fabpot added a commit that referenced this pull request Dec 26, 2015
…mCampbell)

This PR was submitted for the 2.7 branch but it was merged into the 2.3 branch instead (closes #17052).

Discussion
----------

[2.7] Fixed flatten exception recursion with errors

| Q             | A
| ------------- | ---
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | N/A
| License       | MIT
| Doc PR        | N/A

Consider the following code:

```php
$error = new ParseError();

$exception = new RuntimeException($error->getMessage(), $error->getCode(), $error);

$flat = new Symfony\Component\Debug\Exception\FlattenException($exception);
```

Without this fix, that code is broken.

You'll end up with something like this:

```
FatalThrowableError in FlattenException.php line 76:
Type error: Argument 1 passed to Symfony\Component\Debug\Exception\FlattenException::create() must be an instance of Exception, instance of ParseError given
```

---

I came across this error issue in laravel/framework#11329.

Commits
-------

2b0721d [2.7] Fixed flatten exception recursion with errors
@fabpot fabpot closed this Dec 26, 2015
@GrahamCampbell GrahamCampbell deleted the 2.7-throwable branch December 26, 2015 12:18
@GrahamCampbell
Copy link
Contributor Author

:)

fabpot added a commit that referenced this pull request Dec 26, 2015
…s (GrahamCampbell)"

This reverts commit af3f4ea, reversing
changes made to 021ab8a.
fabpot added a commit that referenced this pull request Dec 26, 2015
* 2.3:
  Revert "bug #17052 [2.7] Fixed flatten exception recursion with errors (GrahamCampbell)"
fabpot added a commit that referenced this pull request Dec 26, 2015
…th errors (GrahamCampbell)""

This reverts commit e60889a.
nicolas-grekas added a commit that referenced this pull request Dec 28, 2015
* 2.7:
  [travis] timeout the sigchild tests at 60s
  CS: Single line comments should use double slashes (//) and not hash (#).
  Do not use HttpKernel Extension when not needed for 2.7
  Do not use HttpKernel Extension when not needed
  bumped Symfony version to 2.7.9
  updated VERSION for 2.7.8
  updated CHANGELOG for 2.7.8
  bumped Symfony version to 2.3.37
  updated VERSION for 2.3.36
  update CONTRIBUTORS for 2.3.36
  updated CHANGELOG for 2.3.36
  Revert "Revert "bug #17052 [2.7] Fixed flatten exception recursion with errors (GrahamCampbell)""
  Revert "bug #17052 [2.7] Fixed flatten exception recursion with errors (GrahamCampbell)"
  use nowdoc instead of heredoc

Conflicts:
	src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php
	src/Symfony/Component/HttpKernel/Kernel.php
	src/Symfony/Component/Security/Acl/Dbal/AclProvider.php
	src/Symfony/Component/Security/Acl/Dbal/MutableAclProvider.php
nicolas-grekas added a commit that referenced this pull request Dec 28, 2015
* 2.8:
  [travis] timeout the sigchild tests at 60s
  CS: Single line comments should use double slashes (//) and not hash (#).
  Do not use HttpKernel Extension when not needed for 2.7
  Do not use HttpKernel Extension when not needed
  bumped Symfony version to 2.8.2
  updated VERSION for 2.8.1
  updated CHANGELOG for 2.8.1
  bumped Symfony version to 2.7.9
  updated VERSION for 2.7.8
  updated CHANGELOG for 2.7.8
  bumped Symfony version to 2.3.37
  updated VERSION for 2.3.36
  update CONTRIBUTORS for 2.3.36
  updated CHANGELOG for 2.3.36
  Revert "Revert "bug #17052 [2.7] Fixed flatten exception recursion with errors (GrahamCampbell)""
  Revert "bug #17052 [2.7] Fixed flatten exception recursion with errors (GrahamCampbell)"
  use nowdoc instead of heredoc

Conflicts:
	CHANGELOG-2.3.md
	CHANGELOG-2.7.md
	CHANGELOG-2.8.md
	src/Symfony/Bundle/FrameworkBundle/Command/RouterApacheDumperCommand.php
	src/Symfony/Bundle/WebProfilerBundle/Command/ExportCommand.php
	src/Symfony/Bundle/WebProfilerBundle/Command/ImportCommand.php
	src/Symfony/Component/Console/Shell.php
	src/Symfony/Component/Console/Tests/Helper/LegacyTableHelperTest.php
	src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php
	src/Symfony/Component/HttpKernel/Kernel.php
nicolas-grekas added a commit that referenced this pull request Dec 28, 2015
* 3.0:
  [travis] timeout the sigchild tests at 60s
  CS: Single line comments should use double slashes (//) and not hash (#).
  Do not use HttpKernel Extension when not needed for 2.7
  bumped Symfony version to 3.0.2
  Do not use HttpKernel Extension when not needed
  updated VERSION for 3.0.1
  updated CHANGELOG for 3.0.1
  bumped Symfony version to 2.8.2
  updated VERSION for 2.8.1
  updated CHANGELOG for 2.8.1
  bumped Symfony version to 2.7.9
  updated VERSION for 2.7.8
  updated CHANGELOG for 2.7.8
  bumped Symfony version to 2.3.37
  updated VERSION for 2.3.36
  update CONTRIBUTORS for 2.3.36
  updated CHANGELOG for 2.3.36
  Revert "Revert "bug #17052 [2.7] Fixed flatten exception recursion with errors (GrahamCampbell)""
  Revert "bug #17052 [2.7] Fixed flatten exception recursion with errors (GrahamCampbell)"
  use nowdoc instead of heredoc

Conflicts:
	src/Symfony/Component/HttpKernel/Kernel.php
ostrolucky pushed a commit to ostrolucky/symfony that referenced this pull request Mar 25, 2018
* 2.7:
  [travis] timeout the sigchild tests at 60s
  CS: Single line comments should use double slashes (//) and not hash (#).
  Do not use HttpKernel Extension when not needed for 2.7
  Do not use HttpKernel Extension when not needed
  bumped Symfony version to 2.7.9
  updated VERSION for 2.7.8
  updated CHANGELOG for 2.7.8
  bumped Symfony version to 2.3.37
  updated VERSION for 2.3.36
  update CONTRIBUTORS for 2.3.36
  updated CHANGELOG for 2.3.36
  Revert "Revert "bug symfony#17052 [2.7] Fixed flatten exception recursion with errors (GrahamCampbell)""
  Revert "bug symfony#17052 [2.7] Fixed flatten exception recursion with errors (GrahamCampbell)"
  use nowdoc instead of heredoc

Conflicts:
	src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php
	src/Symfony/Component/HttpKernel/Kernel.php
	src/Symfony/Component/Security/Acl/Dbal/AclProvider.php
	src/Symfony/Component/Security/Acl/Dbal/MutableAclProvider.php
ostrolucky pushed a commit to ostrolucky/symfony that referenced this pull request Mar 25, 2018
* 2.8:
  [travis] timeout the sigchild tests at 60s
  CS: Single line comments should use double slashes (//) and not hash (#).
  Do not use HttpKernel Extension when not needed for 2.7
  Do not use HttpKernel Extension when not needed
  bumped Symfony version to 2.8.2
  updated VERSION for 2.8.1
  updated CHANGELOG for 2.8.1
  bumped Symfony version to 2.7.9
  updated VERSION for 2.7.8
  updated CHANGELOG for 2.7.8
  bumped Symfony version to 2.3.37
  updated VERSION for 2.3.36
  update CONTRIBUTORS for 2.3.36
  updated CHANGELOG for 2.3.36
  Revert "Revert "bug symfony#17052 [2.7] Fixed flatten exception recursion with errors (GrahamCampbell)""
  Revert "bug symfony#17052 [2.7] Fixed flatten exception recursion with errors (GrahamCampbell)"
  use nowdoc instead of heredoc

Conflicts:
	CHANGELOG-2.3.md
	CHANGELOG-2.7.md
	CHANGELOG-2.8.md
	src/Symfony/Bundle/FrameworkBundle/Command/RouterApacheDumperCommand.php
	src/Symfony/Bundle/WebProfilerBundle/Command/ExportCommand.php
	src/Symfony/Bundle/WebProfilerBundle/Command/ImportCommand.php
	src/Symfony/Component/Console/Shell.php
	src/Symfony/Component/Console/Tests/Helper/LegacyTableHelperTest.php
	src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php
	src/Symfony/Component/HttpKernel/Kernel.php
ostrolucky pushed a commit to ostrolucky/symfony that referenced this pull request Mar 25, 2018
* 3.0:
  [travis] timeout the sigchild tests at 60s
  CS: Single line comments should use double slashes (//) and not hash (#).
  Do not use HttpKernel Extension when not needed for 2.7
  bumped Symfony version to 3.0.2
  Do not use HttpKernel Extension when not needed
  updated VERSION for 3.0.1
  updated CHANGELOG for 3.0.1
  bumped Symfony version to 2.8.2
  updated VERSION for 2.8.1
  updated CHANGELOG for 2.8.1
  bumped Symfony version to 2.7.9
  updated VERSION for 2.7.8
  updated CHANGELOG for 2.7.8
  bumped Symfony version to 2.3.37
  updated VERSION for 2.3.36
  update CONTRIBUTORS for 2.3.36
  updated CHANGELOG for 2.3.36
  Revert "Revert "bug symfony#17052 [2.7] Fixed flatten exception recursion with errors (GrahamCampbell)""
  Revert "bug symfony#17052 [2.7] Fixed flatten exception recursion with errors (GrahamCampbell)"
  use nowdoc instead of heredoc

Conflicts:
	src/Symfony/Component/HttpKernel/Kernel.php
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants