-
Problem report
-
Resolution: Fixed
-
Major
-
4.0.21, 5.0.1
-
Sprint 65 (Jun 2020), Sprint 66 (Jul 2020)
-
0.125
API method trends.get automatically filter out non - ITEM_VALUE_TYPE_FLOAT and ITEM_VALUE_TYPE_UINT64 item type, but if one of these types are missed it is possible to catch undefined index:
foreach ([ITEM_VALUE_TYPE_FLOAT, ITEM_VALUE_TYPE_UINT64] as $value_type) { if ($sql_limit !== null && $sql_limit <= 0) { break; } $sql_from = ($value_type == ITEM_VALUE_TYPE_FLOAT) ? 'trends' : 'trends_uint'; if ($options['itemids'][$value_type]) { $sql_where['itemid'] = dbConditionInt('t.itemid', array_keys($options['itemids'][$value_type])); $res = DBselect( 'SELECT '.implode(',', $sql_fields). ' FROM '.$sql_from.' t'. ' WHERE '.implode(' AND ', $sql_where), $sql_limit ); while ($row = DBfetch($res)) { $result[] = $row; } if ($sql_limit !== null) { $sql_limit -= count($result); } } }
when $options['itemids'] does not contain ITEM_VALUE_TYPE_FLOAT or ITEM_VALUE_TYPE_UINT64. So it is possible to cache Undefined index in $options['itemids'][$value_type].