Skip to content

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

Merged
taylorotwell merged 1 commit intolaravel:9.xfrom
luchaos:relative-links
Oct 13, 2022
Merged

[9.x] Fix relative links for regular files#44519
taylorotwell merged 1 commit intolaravel:9.xfrom
luchaos:relative-links

Conversation

@luchaos
Copy link
Copy Markdown
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