Check if the directory exists before iterating

This commit is contained in:
Alexander Rieß 2026-05-19 11:27:41 +02:00
parent 49b9562110
commit f88cffbc17
2 changed files with 10 additions and 5 deletions

View file

@ -90,11 +90,14 @@ class DashboardCspLoader implements CspLoader
if ($this->allUsers) {
$result = [];
foreach (new DirectoryIterator(Config::resolvePath('dashboards')) as $dir) {
$dashboardsDir = Config::resolvePath('dashboards');
if (! is_dir($dashboardsDir)) {
return $result;
}
foreach (new DirectoryIterator($dashboardsDir) as $dir) {
if ($dir->isDot() || ! $dir->isDir()) {
continue;
}
$user = new User($dir->getFilename());
$result = array_merge($result, $this->loadForUser($user));
}

View file

@ -117,12 +117,14 @@ class NavigationCspLoader implements CspLoader
if ($this->allUsers) {
foreach ($navigationTypes as $type => $typeConfig) {
$result = array_merge($result, $this->loadConfig($type, $typeConfig));
foreach (new DirectoryIterator(Config::resolvePath('preferences')) as $userDir) {
$preferencesDir = Config::resolvePath('preferences');
if (! is_dir($preferencesDir)) {
continue;
}
foreach (new DirectoryIterator($preferencesDir) as $userDir) {
if ($userDir->isDot() || ! $userDir->isDir()) {
continue;
}
$result = array_merge($result, $this->loadConfig($type, $typeConfig, $userDir->getFilename()));
}
}