From a3c974778f510150edd0a74b9e570662c95ccfd9 Mon Sep 17 00:00:00 2001 From: Josh Parkinson Date: Mon, 29 Jun 2020 11:13:43 +0100 Subject: [PATCH] Silently fail on 'sites' directory not existing. When determining public file paths if the parent sites directory does not exist and exception is thrown which can break package command execution as well as initial installation (assuming config is defined prior to install). If the sites directory does not exist it is a safe assumption that the files directories do not exist either so silently failing and returning an empty array can be used safely and should not cause any other issues. Catch the base exception as Symfony finder can throw varying exceptions based on (assume) package versions. InvalidArgumentException as well as DirectoryNotFound exceptions. --- src/Installer.php | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/Installer.php b/src/Installer.php index 92129f2..4bc3449 100755 --- a/src/Installer.php +++ b/src/Installer.php @@ -287,12 +287,17 @@ public function install() { * The path list. */ public function getSitesPublicFilesPath() { - $finder = new Finder(); - $finder->in($this->appDir . '/sites') - ->depth(0); - $directories = array(); + try { + $finder = new Finder(); + $finder->in($this->appDir . '/sites') + ->depth(0); + } + catch (\Exception $e) { + return $directories; + } + /** @var \Symfony\Component\Finder\SplFileInfo $directory */ foreach ($finder->directories() as $directory) { $publicFilesPath = 'sites/' . $directory->getFilename() . '/files';