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

Work around PHP phar realpath restrictions #223

Merged
merged 1 commit into from
Mar 20, 2017
Merged

Work around PHP phar realpath restrictions #223

merged 1 commit into from
Mar 20, 2017

Conversation

GrahamCampbell
Copy link
Contributor

PHP's realpath function does not permit evaluating paths within "phar" files. This means that in our service provider, the $source variable is evaluated to false whenever someone tries to package up "bugsnag-laravel" in a "phar":

    protected function setupConfig(Container $app)
    {
        $source = realpath(__DIR__.'/../config/bugsnag.php');

        if ($app instanceof LaravelApplication && $app->runningInConsole()) {
            $this->publishes([$source => config_path('bugsnag.php')]);
        } elseif ($app instanceof LumenApplication) {
            $app->configure('bugsnag');
        }

        $this->mergeConfigFrom($source, 'bugsnag');
    }

This can be mitigated by replacing the first line of the function body with:

$source = realpath($raw = __DIR__.'/../config/bugsnag.php') ?: $raw;

since it's not absolutely required to use the "real path".

This change just falls back to the relative path if we are not able to compute the real path.


Closes #222. Related: https://bugs.php.net/bug.php?id=52769.

Thanks to @praalhans for the report.

@GrahamCampbell GrahamCampbell added the bug Confirmed bug label Mar 18, 2017
@kattrali
Copy link
Contributor

Makes sense. Thanks for the fix, @GrahamCampbell. 😄

@kattrali kattrali merged commit 53086dd into master Mar 20, 2017
@kattrali kattrali deleted the phar branch March 20, 2017 20:13
GrahamCampbell referenced this pull request in GrahamCampbell/Laravel-Exceptions Jan 2, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Confirmed bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants