Uploaded image for project: 'ZABBIX BUGS AND ISSUES'
  1. ZABBIX BUGS AND ISSUES
  2. ZBX-17960

Undefined index in API method: trend.get

XMLWordPrintable

    • 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].

            talbergs Mārtiņš Tālbergs (Inactive)
            dotneft Alexey Pustovalov
            Team B
            Votes:
            1 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved: