mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
fix: Added more safety checking into create_state_index() so we do not end up with stale state names but no translation (#6516)
This commit is contained in:
committed by
Tony Murray
parent
153f0de12f
commit
d67d62eacb
@ -1650,9 +1650,16 @@ function rrdtest($path, &$stdOutput, &$stdError)
|
||||
|
||||
function create_state_index($state_name)
|
||||
{
|
||||
if (dbFetchRow('SELECT * FROM state_indexes WHERE state_name = ?', array($state_name)) != true) {
|
||||
$state_index_id = dbFetchCell('SELECT `state_index_id` FROM state_indexes WHERE state_name = ? LIMIT 1', array($state_name));
|
||||
if (!is_numeric($state_index_id)) {
|
||||
$insert = array('state_name' => $state_name);
|
||||
return dbInsert($insert, 'state_indexes');
|
||||
} else {
|
||||
$translations = dbFetchRows('SELECT * FROM `state_translations` WHERE `state_index_id` = ?', array($state_index_id));
|
||||
if (count($translations) === 0) {
|
||||
// If we don't have any translations something has gone wrong so return the state_index_id so they get created.
|
||||
return $state_index_id;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user