cleanup device type override code (#13256)

This commit is contained in:
Tony Murray
2021-09-27 07:24:32 -05:00
committed by GitHub
parent dda46447c3
commit b934d0c927
3 changed files with 7 additions and 6 deletions

View File

@@ -994,11 +994,11 @@ function load_os(&$device)
// Set type to a predefined type for the OS if it's not already set
$loaded_os_type = Config::get("os.{$device['os']}.type");
if ((! isset($device['attribs']['override_device_type']) && $device['attribs']['override_device_type'] != 1) && array_key_exists('type', $device) && $loaded_os_type != $device['type']) {
log_event('Device type changed ' . $device['type'] . ' => ' . $loaded_os_type, $device, 'system', 3);
$device['type'] = $loaded_os_type;
dbUpdate(['type' => $loaded_os_type], 'devices', 'device_id=?', [$device['device_id']]);
d_echo("Device type changed to $loaded_os_type!\n");
$model = DeviceCache::get($device['device_id']);
if (! $model->getAttrib('override_device_type') && $loaded_os_type != $model->type) {
$model->type = $loaded_os_type;
$model->save();
Log::debug("Device type changed to $loaded_os_type!");
}
if ($os_group = Config::get("os.{$device['os']}.group")) {