Skip to content
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] Improve fileLinkFormat handling #50734

Merged
merged 1 commit into from Oct 16, 2023

Conversation

nlemoine
Copy link
Contributor

@nlemoine nlemoine commented Jun 21, 2023

Q A
Branch? 6.4
Bug fix? no
New feature? yes
Deprecations? yes
Tickets Fix #50619
License MIT
Doc PR
  • Avoid repeating file link format guessing (logic is already in FileLinkFormatter class)
  • Always set a fileLinkFormat to a FileLinkFormatter object to handle path mappings properly

@carsonbot
Copy link

Hey!

I see that this is your first PR. That is great! Welcome!

Symfony has a contribution guide which I suggest you to read.

In short:

  • Always add tests
  • Keep backward compatibility (see https://symfony.com/bc).
  • Bug fixes must be submitted against the lowest maintained branch where they apply (see https://symfony.com/releases)
  • Features and deprecations must be submitted against the 6.4 branch.

Review the GitHub status checks of your pull request and try to solve the reported issues. If some tests are failing, try to see if they are failing because of this change.

When two Symfony core team members approve this change, it will be merged and you will become an official Symfony contributor!
If this PR is merged in a lower version branch, it will be merged up to all maintained branches within a few days.

I am going to sit back now and wait for the reviews.

Cheers!

Carsonbot

@nlemoine nlemoine force-pushed the ErrorHandler/ImproveFileLinkFormat branch 3 times, most recently from 58c831b to 81c102d Compare June 21, 2023 19:36
@GromNaN GromNaN self-requested a review June 23, 2023 09:23
Copy link
Member

@GromNaN GromNaN left a comment

Choose a reason for hiding this comment

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

Using the Symfony\Component\HttpKernel\Debug\FileLinkFormatter in Symfony\Component\ErrorHandler\ErrorRenderer\HtmlErrorRenderer is a good idea, but the 2 classes are not in the same composer packages.
I think the FileLinkFormatter should be moved to symfony/error-handler: this package is already required by symfony/http-kernel, but not in the other direction.

This can be done in a backward-compatible way by replacing the class with:

namespace Symfony\Component\HttpKernel\Debug;

use Symfony\Component\ErrorHandler\ErrorRenderer\FileLinkFormatter as NewFileLinkFormatter;

/** @deprecated since 6.4, use Symfony\Component\ErrorHandler\ErrorRenderer\FileLinkFormatter */
class FileLinkFormatter extends NewFileLinkFormatter
{
    // Inherit all the methods from the parent
}

I'll just ask @symfony/mergers opinion before you can start editing if you wish.

@nlemoine
Copy link
Contributor Author

nlemoine commented Jun 23, 2023

Using the Symfony\Component\HttpKernel\Debug\FileLinkFormatter in Symfony\Component\ErrorHandler\ErrorRenderer\HtmlErrorRenderer is a good idea, but the 2 classes are not in the same composer packages.

That would be great! My original issue about was actually aiming to consolidate file link formatting and make it more consistent across components. Some business logic, that's already contained in FileLinkFormatter class, is repeated in various places:

Probably all those statements could be replaced with something like (long version):

if ($fileLinkFormat instanceof FileLinkFormatter) {
    $this->fileLinkFormat = $fileLinkFormat;
} else {
    $this->fileLinkFormat = class_exists(FileLinkFormatter::class) ? new FileLinkFormatter() : $fileLinkFormat;
}

What do you think @GromNaN?

I'll just ask @symfony/mergers opinion before you can start editing if you wish.

That would be welcome!

@nlemoine nlemoine force-pushed the ErrorHandler/ImproveFileLinkFormat branch from 29f3941 to 32346bf Compare June 23, 2023 13:57
@nicolas-grekas nicolas-grekas changed the title [ErrorHandler] Improve fileLinkFormat handling (#50619) [ErrorHandler] Improve fileLinkFormat handling Oct 16, 2023
@nicolas-grekas nicolas-grekas force-pushed the ErrorHandler/ImproveFileLinkFormat branch from 32346bf to 3cc9728 Compare October 16, 2023 19:50
- Avoid repeating file link format guessing (logic is already in FileLinkFormatter class)
- Always set a fileLinkFormat to a FileLinkFormatter object to handle path mappings properly
@nicolas-grekas nicolas-grekas force-pushed the ErrorHandler/ImproveFileLinkFormat branch from 3cc9728 to 510b77b Compare October 16, 2023 20:02
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 updated all references to the deprecated namespace.
This should be good to do (despite tests)

@fabpot
Copy link
Member

fabpot commented Oct 16, 2023

Thank you @nlemoine.

nicolas-grekas added a commit that referenced this pull request Oct 17, 2023
…fancyweb)

This PR was merged into the 6.4 branch.

Discussion
----------

[ErrorHandler] Fix file link format call in trace view

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

Leftover from #50734

Commits
-------

c2f01c2 [ErrorHandler] Fix file link format call in trace view
nicolas-grekas added a commit that referenced this pull request Oct 17, 2023
…dre-daubois)

This PR was merged into the 6.4 branch.

Discussion
----------

[ErrorHandler] Fix expected missing return types

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

Follow up of #50734

Commits
-------

842e6ab [ErrorHandler] Fix expected missing return types
@nlemoine nlemoine deleted the ErrorHandler/ImproveFileLinkFormat branch October 17, 2023 12:59
@nlemoine
Copy link
Contributor Author

Great, thanks!

This was referenced Oct 21, 2023
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.

Improve fileLinkFormat / SYMFONY_IDE configuration outside Symfony
5 participants