Skip to content
Snippets Groups Projects

Resolve #3408488 "Make unknownpathexcluder accept"

Compare and Show latest version
1 file
+ 10
7
Compare changes
  • Side-by-side
  • Inline
@@ -74,18 +74,18 @@ final class UnknownPathExcluder implements EventSubscriberInterface {
$known_paths[] = [$web_root];
$project_root = $this->pathLocator->getProjectRoot();
// To determine the scaffold files to exclude, the installed packages must
// be known, and that requires Composer commands to be able to run. This
// intentionally does not catch exceptions: failed Composer validation in
// the project root implies that this excluder cannot function correctly.
// To determine the files to exclude, the installed packages must be known,
// and that requires Composer commands to be able to run. This intentionally
// does not catch exceptions: failed Composer validation in the project root
// implies that this excluder cannot function correctly.
// Note: the call to ComposerInspector::getInstalledPackagesList() would
// also have triggered this, but explicitness is preferred here.
// @see \Drupal\package_manager\StatusCheckTrait::runStatusCheck()
$this->composerInspector->validate($project_root);
// The vendor directory is always a known path.
// The vendor directory is always a known path, as are the `composer.json`
// and `composer.lock` files.
$known_paths[] = $this->composerInspector->getConfig('vendor-dir', $project_root);
// So are the `composer.json` and `composer.lock` files.
$known_paths[] = 'composer.json';
$known_paths[] = 'composer.lock';
@@ -111,7 +111,10 @@ final class UnknownPathExcluder implements EventSubscriberInterface {
// glob() flags aren't supported on all systems. We also can't use
// \Drupal\Core\File\FileSystemInterface::scanDirectory(), because it
// unconditionally ignores hidden files and directories.
$handle = opendir($project_root) ?: throw new \RuntimeException("Could not scan for files in the project root.");
$handle = opendir($project_root);
if (empty($handle)) {
throw new \RuntimeException("Could not scan for files in the project root.");
}
while ($entry = readdir($handle)) {
if ($entry === '.' || $entry === '..' || in_array($entry, $known_paths, TRUE)) {
continue;
Loading