mirror of
https://github.com/Icinga/icingaweb2.git
synced 2026-06-11 01:20:21 -04:00
Check if the directory exists before iterating
This commit is contained in:
parent
49b9562110
commit
f88cffbc17
2 changed files with 10 additions and 5 deletions
|
|
@ -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));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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()));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue