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

[9.x] Fix relative links for regular files #44519

Merged
merged 1 commit into from
Oct 13, 2022

Conversation

luchaos
Copy link
Contributor

@luchaos luchaos commented Oct 8, 2022

Laravel's storage:link --relative command breaks when configuring paths to regular files.

How to reproduce

Add symfony/filesystem to support relative links:

composer require symfony/filesystem

Add link to regular file in config/filesystems.php:

'links' => [
    public_path('README.md') => base_path('README.md'),
],

Run storage link command with relative option:

php artisan storage:link --relative

Results in...

  ErrorException 

  symlink(): No such file or directory

... because the relative path now has a trailing slash: ../README.md/.

This PR mitigates a bug in Symfony's filesystem component which dates back all the way to 2012, introduced in Laravel 8.x.

I wouldn't expect this bug to be fixed in Symfony itself anytime soon given its history. The fix on Laravel's framework level is simple enough without breaking any existing behaviour (I don't think this particular case ever worked in the first place).

This could be backported to 8.x easily if desired; adhering to the support policy.

@taylorotwell taylorotwell merged commit 6b9e377 into laravel:9.x Oct 13, 2022
@luchaos luchaos deleted the relative-links branch October 13, 2022 16:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants