Skip to content

[Console] Suppress unhandled error in some specific use-cases. #46291

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 10, 2022

Conversation

rw4lll
Copy link
Contributor

@rw4lll rw4lll commented May 8, 2022

Q A
Branch? 5.4
Bug fix? yes
New feature? no
Deprecations? no
Tickets Fix #...
License MIT
Doc PR symfony/symfony-docs#...

If the package is used not in console with open_basedir enabled, since 5.4 it fails with unhandled php error here:
(https://github.com/symfony/console/blob/06974380c667d7d8e3cd0f24bf51f816a71ca6c6/Command/DumpCompletionCommand.php#L44) because of trying to call realpath("/") and, of course, it's not allowed.

It's a very specific use-case for Symfony, but can happen if it's used as dependency, e.g. in Laravel. I've described it in details here: laravel/framework#42171

I think that the best would be just suppress the error in that case.

@rw4lll rw4lll requested a review from chalasr as a code owner May 8, 2022 12:49
@carsonbot carsonbot added this to the 5.4 milestone May 8, 2022
@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.1 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

@carsonbot
Copy link

Hey!

I think @dkarlovi has recently worked with this code. Maybe they can help review this?

Cheers!

Carsonbot

@dkarlovi
Copy link
Contributor

dkarlovi commented May 9, 2022

@rw4lll reading the related Laravel issue, you mention this happens when the command is invoked in web context? That should basically never happen. If it does, it should be up to the invoker (I guess, Artisan?) to handle these issues on its side, maybe by introducing a custom error handler or similar?

In any case, I'm 👎 here.

Copy link
Member

@wouterj wouterj left a comment

Choose a reason for hiding this comment

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

Hi. Thanks for the PR.

Given this is a default command, and configure() is called automatically when instantiating the Application, I agree that suppressing the error is the best way forward. Otherwise, any user of the Console component will have this error when using open_basedir.


For reference, Symfony overrides the Application class from the component in the FrameworkBundle and uses lazy loading of all commands. This means that in a Symfony application, configure() is only called when the command is called. This means that it is indeed unlikely to get this error when using the Symfony full-stack framework.

@carsonbot carsonbot changed the title Suppress unhandled error in some specific use-cases. [Console] Suppress unhandled error in some specific use-cases. May 9, 2022
@nicolas-grekas
Copy link
Member

Thank you @rw4lll.

@nicolas-grekas nicolas-grekas merged commit 60836ff into symfony:5.4 May 10, 2022
@fabpot fabpot mentioned this pull request May 14, 2022
This was referenced May 27, 2022
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.

6 participants