Skip to content

[Process] Workaround buggy PHP warning #16182

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 3 commits into from
Closed

[Process] Workaround buggy PHP warning #16182

wants to merge 3 commits into from

Conversation

cbj4074
Copy link
Contributor

@cbj4074 cbj4074 commented Oct 9, 2015

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

This temporary workaround is intended to address an uncaught exception that may occur, until https://bugs.php.net/bug.php?id=69240 is fixed.

Obviously the @ operator is another option, but I'm erring towards the notion that the Symfony authors/maintainers may wish to implement more elegant exception-handling logic than simply using @.

This temporary workaround is intended to address an uncaught exception that may occur, until https://bugs.php.net/bug.php?id=69240 is fixed.

Obviously the `@` operator is another option, but I'm erring towards the notion that the Symfony authors/maintainers may wish to implement more elegant exception-handling logic than simply using `@`.
@stof
Copy link
Member

stof commented Oct 9, 2015

catching ErrorException is the wrong implementation. Warnings are not turned into exceptions in production

}
}
catch (\ErrorException $e) {
Copy link
Member

Choose a reason for hiding this comment

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

who triggers the exception?

Copy link
Contributor

Choose a reason for hiding this comment

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

is_dir, see the comment above.

Copy link
Member

Choose a reason for hiding this comment

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

is_dir triggers warnings, not exceptions. A custom error handler must be registered for an exception to be thrown.
The implementation with an @ is required (same as @stof comments)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@nicolas-grekas I replaced the try/catch with an @.

The relevant stack frame contains HandleExceptions->handleError('2', 'is_dir(): open_basedir restriction in effect. File(/srv/www/example.com/web) is not within the allowed path(s) ... where HandleExceptions is an instance of Illuminate\Foundation\Bootstrap\HandleExceptions.

@cbj4074
Copy link
Contributor Author

cbj4074 commented Oct 9, 2015

@stof Okay; my apologies. I am not at all familiar with the Symfony code-base, nor the methodologies that it employs. As much as I would love to read-up and offer a more appropriate solution, I simply lack the time. Perhaps you or another contributor is able to discern the problem and fix it correctly.

@nicolas-grekas From what I'm able to determine, PHP's is_dir() method triggers the exception. The behavior results from a confirmed bug in PHP (see PR description for link to issue).

@@ -56,7 +56,7 @@ public function find($name, $default = null, array $extraDirs = array())
$searchPath = explode(PATH_SEPARATOR, ini_get('open_basedir'));
$dirs = array();
foreach ($searchPath as $path) {
if (is_dir($path)) {
if (@is_dir($path)) {
Copy link
Member

Choose a reason for hiding this comment

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

LGTM, can you just add a comment like this one please?

// Silencing against https://bugs.php.net/69240

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done. Please let me know if you had something different in mind. Thanks!

@nicolas-grekas
Copy link
Member

👍 thanks

@nicolas-grekas nicolas-grekas changed the title Add temporary workaround for known PHP bug [Process] Workaround buggy PHP warning Oct 9, 2015
@xabbuh
Copy link
Member

xabbuh commented Oct 9, 2015

👍

@cbj4074
Copy link
Contributor Author

cbj4074 commented Oct 9, 2015

Thanks for the quick turnaround! 🍻

@Tobion
Copy link
Contributor

Tobion commented Oct 9, 2015

Thank you @cbj4074.

Tobion added a commit that referenced this pull request Oct 9, 2015
This PR was submitted for the 2.8 branch but it was merged into the 2.3 branch instead (closes #16182).

Discussion
----------

[Process] Workaround buggy PHP warning

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

This temporary workaround is intended to address an uncaught exception that may occur, until https://bugs.php.net/bug.php?id=69240 is fixed.

Obviously the `@` operator is another option, but I'm erring towards the notion that the Symfony authors/maintainers may wish to implement more elegant exception-handling logic than simply using `@`.

Commits
-------

b1bd093 [Process] Workaround buggy PHP warning
@Tobion Tobion closed this Oct 9, 2015
@xabbuh xabbuh added the Process label Oct 10, 2015
This was referenced Oct 27, 2015
@cbj4074 cbj4074 deleted the patch-1 branch November 10, 2015 16:51
nicolas-grekas added a commit that referenced this pull request May 15, 2018
… (cbj4074)

This PR was merged into the 2.7 branch.

Discussion
----------

[Process] Suppress warnings when open_basedir is non-empty

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

If PHP is configured *with a non-empty open_basedir* value that does not permit access to the target location, these calls to is_executable() throw warnings.

While Symfony may not raise exceptions for warnings in production environments, other frameworks (such as Laravel) do, in which case any of these checks causes a show-stopping 500 error.

We fixed a similar issue in the ExecutableFinder class via #16182 .

This has always been an issue, but symfony/process@709e15e made it more likely that a warning is triggered.

Commits
-------

34f136e Suppress warnings when open_basedir is non-empty
symfony-splitter pushed a commit to symfony/process that referenced this pull request May 15, 2018
If PHP is configured *with a non-empty open_basedir* value that does not permit access to the target location, these calls to is_executable() throw warnings.

While Symfony may not raise exceptions for warnings in production environments, other frameworks (such as Laravel) do, in which case any of these checks causes a show-stopping 500 error.

We fixed a similar issue in the ExecutableFinder class via symfony/symfony#16182 .

This has always been an issue, but 709e15e made it more likely that a warning is triggered.
symfony-splitter pushed a commit to symfony/process that referenced this pull request May 15, 2018
… (cbj4074)

This PR was merged into the 2.7 branch.

Discussion
----------

[Process] Suppress warnings when open_basedir is non-empty

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

If PHP is configured *with a non-empty open_basedir* value that does not permit access to the target location, these calls to is_executable() throw warnings.

While Symfony may not raise exceptions for warnings in production environments, other frameworks (such as Laravel) do, in which case any of these checks causes a show-stopping 500 error.

We fixed a similar issue in the ExecutableFinder class via symfony/symfony#16182 .

This has always been an issue, but 709e15e made it more likely that a warning is triggered.

Commits
-------

34f136e01b Suppress warnings when open_basedir is non-empty
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.

7 participants