Stop looping after the file is found, otherwise $config might contain another path then the one where te file is found. This causes problems when $config is used as working directory for fetching changes in git. (#10942)

Also, this is a small performance improvement.
This commit is contained in:
Jurrian van Iersel
2019-12-14 21:03:58 +01:00
committed by Kevin Krumm
parent b2137787fb
commit 5bf56db50a

View File

@@ -17,12 +17,15 @@ if (Auth::user()->hasGlobalAdmin()) {
if (is_file($configs.$device['hostname'])) { if (is_file($configs.$device['hostname'])) {
$file = $configs.$device['hostname']; $file = $configs.$device['hostname'];
break;
} elseif (is_file($configs.strtok($device['hostname'], '.'))) { // Strip domain } elseif (is_file($configs.strtok($device['hostname'], '.'))) { // Strip domain
$file = $configs.strtok($device['hostname'], '.'); $file = $configs.strtok($device['hostname'], '.');
break;
} else { } else {
if (!empty(Config::get('mydomain'))) { // Try with domain name if set if (!empty(Config::get('mydomain'))) { // Try with domain name if set
if (is_file($configs.$device['hostname'].'.'.Config::get('mydomain'))) { if (is_file($configs.$device['hostname'].'.'.Config::get('mydomain'))) {
$file = $configs.$device['hostname'].'.'.Config::get('mydomain'); $file = $configs.$device['hostname'].'.'.Config::get('mydomain');
break;
} }
} }
} // end if } // end if