mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Fix short name generation
Should only replace first occurrence of prefix in the string. Also only strips the prefix if it saves more than 2 characters. This fixes a bug where, e.g., 'casnDisconnect' would be shortened to 'asnDisonnet'.
This commit is contained in:
@@ -1189,8 +1189,10 @@ function load_mibdefs($module, $name)
|
||||
|
||||
// add shortname to each element
|
||||
$prefix = longest_matching_prefix($name, $object_types);
|
||||
foreach ($result as $mib => $m) {
|
||||
$result[$mib]['shortname'] = str_replace($prefix, '', $m['object_type']);
|
||||
if (strlen($prefix) > 2) {
|
||||
foreach ($result as $mib => $m) {
|
||||
$result[$mib]['shortname'] = preg_replace("/^$prefix/", '', $m['object_type'], 1);
|
||||
}
|
||||
}
|
||||
|
||||
d_print_r($result);
|
||||
|
||||
Reference in New Issue
Block a user