-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[ErrorHandler] Handle PHP 8.3 highlight_file
function output changes
#51586
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
[ErrorHandler] Handle PHP 8.3 highlight_file
function output changes
#51586
Conversation
d73b6c0
to
ad10b00
Compare
Thank you. Does this affect 5.4 or 6.3 as well? If that's the case, please retarget your PR. |
looks like it needs to be 5.4.
|
ad10b00
to
5f260a3
Compare
5f260a3
to
b4190db
Compare
b4190db
to
809cf74
Compare
its late and my eyes sleepy, but I think Ive downgraded it ok, and removed short function syntax in my original to be compatible with PHP 7 also. Should be ok to test now. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's very important to update Symfony for this BC-break in PHP 8.3. Thanks Phil for taking care of this!
Thank you @PhilETaylor. |
… PHP 8.3 (tscni) This PR was merged into the 5.4 branch. Discussion ---------- [ErrorHandler] Fix rendered exception code highlighting on PHP 8.3 | Q | A | ------------- | --- | Branch? | 5.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Issues | Fix #57354 | License | MIT #51586 made some mistakes when fixing the use of `highlight_file()` for PHP 8.3: - It assumed that the inner `<span>` were changed to `<code>` - It did not properly adjust the pattern for `\n` when splitting the highlighting across multiple lines - It replaced all spaces with ` `, including those inside tags, breaking the highlighting entirely The first two are easy to fix. The latter one not so much without CSS adjustments. But just changing `white-space: nowrap` to `white-space: pre` would remove the need for that. I'm a bit worried about side effects though and I'm not sure if `CodeExtension` uses separate styling somewhere, but I can't find anything problematic at least. A test would be a bit cumbersome to add for this, so unless very much preferred I'd rather not spend the time on it. But at least in manual tests this resolved all the highlighting issues. Commits ------- 2b46e2a [ErrorHandler] Fix rendered exception code highlighting on PHP 8.3
PHP 8.3 changes the output from the
highlight_file
function as described here: https://php.watch/versions/8.3/highlight_file-highlight_string-html-changesI accidentally ran into this head first when using PHP 8.3.0-RC1 in development with Symfony 6.4-dev when my error had no code rendered
Also affected the
{{ '/path/to/file.html.twig'|file_excerpt(140,5) }}
twig codefile_except
renderer - easier to replicate with that code just throw it into your twig file with a valid/path/to/file.html.twig
- before this PR there would be no output, after this PR the file except would be shown.Same fix applied to both files.
After this fix the code rendered returned.