Skip to content

[HttpKernel] Allow ErrorHandler ^5.0 to be used in HttpKernel 4.4 #46327

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

Merged
merged 1 commit into from
May 11, 2022

Conversation

mpdude
Copy link
Contributor

@mpdude mpdude commented May 11, 2022

Q A
Branch? 4.4
Bug fix? no
New feature? yes
Deprecations? no
Tickets
License MIT
Doc PR

I wonder what prevents us from allowing HttpKernel ^4.4 to be used with ErrorHandler ^5.0?

ErrorHandler 5.4 (IIRC) adds the incredibly helpful feature ❤️‍🔥 to emit deprecation notices for missing return type hints. This is valuable when trying to migrate larger codebases to make use of type hints.

Symfony 4.4 is the current LTS, and this PR would allow people to switch to ErrorHandler 5.4 while the rest of the code can still use Symfony 4.4 components.

@carsonbot carsonbot added this to the 4.4 milestone May 11, 2022
@mpdude mpdude changed the title Allow ErrorHandler ^5.0 to be used in HttpKernel Allow ErrorHandler ^5.0 to be used in HttpKernel 4.4 May 11, 2022
@carsonbot carsonbot changed the title Allow ErrorHandler ^5.0 to be used in HttpKernel 4.4 [HttpKernel] Allow ErrorHandler ^5.0 to be used in HttpKernel 4.4 May 11, 2022
@derrabus derrabus requested a review from nicolas-grekas May 11, 2022 15:26
@derrabus derrabus added Bug and removed Feature labels May 11, 2022
@derrabus
Copy link
Member

I wonder what prevents us from allowing HttpKernel ^4.4 to be used with ErrorHandler ^5.0?

This was done in 7ec445b by @nicolas-grekas. Not sure if he still knows why he did that back then.

Copy link
Member

@nicolas-grekas nicolas-grekas left a comment

Choose a reason for hiding this comment

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

I don't remember, certainly an issue with the CI, but it's green now 🤷
Works for me since most projects will use flex to still force 4.4 so they won't be affected.

@derrabus
Copy link
Member

Thank you Matthias.

@derrabus derrabus merged commit 1e317cc into symfony:4.4 May 11, 2022
@mpdude
Copy link
Contributor Author

mpdude commented May 11, 2022

Your pace is awesome, thank you guys!

@mpdude mpdude deleted the allow-error-handler-5 branch May 11, 2022 16:49
@mpdude
Copy link
Contributor Author

mpdude commented May 13, 2022

⚠️ see comment at symfony/http-kernel@486baf0.

Cannot tell right now if that’s an incompatibility between Symfony packages and/or the person did not declare their dependencies correctly.

mpdude referenced this pull request in symfony/http-kernel May 13, 2022
@stof
Copy link
Member

stof commented May 13, 2022

Well, they probably don't have a direct dependency on symfony/error-handler in their project, and upgrading to version 5 of the error handler removed the BC layer with symfony/debug (but for a project upgrading Symfony 4 from minor to minor, not having a requirement on symfony/error-handler is quite expected as earlier versions of symfony/http-kernel were using symfony/debug for that feature)

@mpdude
Copy link
Contributor Author

mpdude commented May 14, 2022

I think the situation is as follows:

  • The ExceptionController in TwigBundle 4.4 expects a Symfony\Component\Debug\Exception\FlattenException (here)
  • In ErrorHandler 4.4, the Symfony\Component\ErrorHandler\Exception\FlattenException is a subclass of the (at that time already deprecated) Symfony\Component\Debug\Exception\FlattenException
  • With the change from this PR, ErrorHandler 5.x may be installed, where Symfony\Component\ErrorHandler\Exception\FlattenException no longer extends the legacy base class (here)

I might be wrong, but is this a missing depencendy declaration (either requires or maybe conflicts) in TwigBundle 4.4 against either ErrorHandler or the Debug component?

Reasons against this: TwigBundle does not require either one, and also has no problem when ErrorHandler 5.x is installed... it just can't handle exceptions generated in ErrorHandler 5.x.

Another suggestion: I could change the ExceptionController in TwigBundle 4.4 to be kind of forwards-compatible and accept either Exceptions from Debug or ErrorHandler. But that change would probably be breaking BC for users inheriting from that Controller and overwriting the method, right?

@fabpot fabpot mentioned this pull request May 14, 2022
@mpdude
Copy link
Contributor Author

mpdude commented May 16, 2022

Would it be OK if ErrorHandler's FlattenException in 5.4 would still inherit from Symfony\Component\Debug\Exception\FlattenException if that class exists (decided at runtime)?

@nicolas-grekas
Copy link
Member

The point of doing a major version bump is to get rid of those hacks. I think we should revert this PR. That's quite unfortunate but we cannot afford breaking existing stacks I fear.

@stof
Copy link
Member

stof commented May 16, 2022

I agree about reverting that PR.

@mpdude
Copy link
Contributor Author

mpdude commented May 16, 2022

Also agree!

@mpdude
Copy link
Contributor Author

mpdude commented May 16, 2022

Should we learn from this that some kind of test is missing… if so, what might that be?

@stof
Copy link
Member

stof commented May 16, 2022

The missing test would be a functional test triggering the rendering of an error page.

nicolas-grekas added a commit to nicolas-grekas/symfony that referenced this pull request May 16, 2022
…used in HttpKernel 4.4 (mpdude)"

This reverts commit 1e317cc, reversing
changes made to 129a271.
@nicolas-grekas
Copy link
Member

Reverted in #46365

nicolas-grekas added a commit that referenced this pull request May 16, 2022
… be used" (nicolas-grekas)

This PR was merged into the 4.4 branch.

Discussion
----------

[HttpKernel] Revert "bug #46327  Allow ErrorHandler ^5.0 to be used"

| Q             | A
| ------------- | ---
| Branch?       | 4.4
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Tickets       | -
| License       | MIT
| Doc PR        | -

This reverts commit 1e317cc, reversing
changes made to 129a271.

As discussed in #46327

Commits
-------

c206591 Revert "bug #46327 [HttpKernel] Allow ErrorHandler ^5.0 to be used in HttpKernel 4.4 (mpdude)"
nicolas-grekas added a commit that referenced this pull request May 17, 2022
* 4.4:
  [Mime] Add null check for EmailHeaderSame
  Add approriate description to CollectionToArrayTransformer::reverseTransform docblock
  [PropertyInfo] CS fixes
  [VarDumper] fix test on PHP 8.2
  [Config] Fix looking for single files in phars with GlobResource
  Revert "bug #46327 [HttpKernel] Allow ErrorHandler ^5.0 to be used in HttpKernel 4.4 (mpdude)"
nicolas-grekas added a commit that referenced this pull request May 17, 2022
* 5.4:
  [VarDumper] fix tests on PHP 8.2
  [Mime] Add null check for EmailHeaderSame
  Add approriate description to CollectionToArrayTransformer::reverseTransform docblock
  [PropertyInfo] CS fixes
  [VarDumper] fix test on PHP 8.2
  [Config] Fix looking for single files in phars with GlobResource
  Revert "bug #46327 [HttpKernel] Allow ErrorHandler ^5.0 to be used in HttpKernel 4.4 (mpdude)"
nicolas-grekas added a commit that referenced this pull request May 17, 2022
* 6.0:
  [VarDumper] fix tests on PHP 8.2
  [Mime] Add null check for EmailHeaderSame
  Add approriate description to CollectionToArrayTransformer::reverseTransform docblock
  [PropertyInfo] CS fixes
  [VarDumper] fix test on PHP 8.2
  [Config] Fix looking for single files in phars with GlobResource
  Revert "bug #46327 [HttpKernel] Allow ErrorHandler ^5.0 to be used in HttpKernel 4.4 (mpdude)"
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