Skip to content

Commit

Permalink
Fix path to files directory when it is a symlink (#6047)
Browse files Browse the repository at this point in the history
* Fix path to files directory when it is a symlink

* Convert back to full path prior to calling realpath()

* Fix path logic

* Remove unused function

* Remove path repositories from consideration

* We don't actually need the relative path
  • Loading branch information
greg-1-anderson authored Jun 22, 2024
1 parent 5cb8282 commit 8389f62
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/Commands/core/ArchiveDumpCommands.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace Drush\Commands\core;

use Drupal;
use Drupal\Core\StreamWrapper\PublicStream;
use Drush\Attributes as CLI;
use Drush\Boot\DrupalBootLevels;
use Drush\Commands\DrushCommands;
Expand Down Expand Up @@ -381,6 +382,10 @@ private function getCodeComponentPath(array $options): string
$process->mustRun();
$composerInfoRaw = $process->getOutput();
$installedPackages = json_decode($composerInfoRaw, true)['installed'] ?? [];
// Remove path projects ('source' is empty for path projects)
$installedPackages = array_filter($installedPackages, function ($dependency) {
return !empty($dependency['source']);
});
$installedPackagesPaths = array_filter(array_column($installedPackages, 'path'));
$installedPackagesRelativePaths = array_map(
fn($path) => ltrim(str_replace([$this->getComposerRoot()], '', $path), '/'),
Expand Down Expand Up @@ -451,8 +456,7 @@ private function getDrupalFilesComponentPath(): string
}

/**
* Returns the path to Drupal files directory.
*
* Returns the full path to Drupal files directory.
*
* @throws \Exception
*/
Expand All @@ -463,7 +467,7 @@ private function getDrupalFilesDir(): string
}

Drush::bootstrapManager()->doBootstrap(DrupalBootLevels::FULL);
$drupalFilesPath = Drupal::service('file_system')->realpath('public://');
$drupalFilesPath = Path::join($this->getRoot(), PublicStream::basePath());
if (!$drupalFilesPath) {
throw new Exception(dt('Path to Drupal files is empty.'));
}
Expand Down

0 comments on commit 8389f62

Please sign in to comment.