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

[6.x] Delete existing links that are broken #36470

Merged
merged 1 commit into from
Mar 5, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Delete existing links that are broken
When a link exists but is broken, `file_exists($link)` return false. And
when `symlink($link, $target)` is called on a broken link, a PHP Warning
is returned and the link is not updated. To fix this, we add an
additional check using `is_link($link)` (which return true, even if the
link is broken) to detect and delete broken links.
  • Loading branch information
pgrenaud committed Mar 4, 2021
commit 4876bfd58a2ec7d29c28789eb9d56cc94009f33c
4 changes: 4 additions & 0 deletions src/Illuminate/Foundation/Console/StorageLinkCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ public function handle()
return $this->error('The "public/storage" directory already exists.');
}

if (is_link(public_path('storage'))) {
$this->laravel->make('files')->delete(public_path('storage'));
}

$this->laravel->make('files')->link(
storage_path('app/public'), public_path('storage')
);
Expand Down