ExportXMLWordPrintable

    • Type: Problem report
    • Resolution: Unresolved
    • Priority: Trivial
    • None
    • Affects Version/s: 8.0.0
    • Component/s: Frontend (F)
    • Environment:
      Zabbix 8.0.0 server and frontend, Debian 12 packages (zabbix-frontend-php 2:8.0.0-1+debian12), PHP 8.2.36, upgraded from 7.4.

      Steps to reproduce:

      1. On a template, create a template dashboard with a Graph widget.
      2. Add a data set with an item pattern, e.g. My API * Response Time (no host pattern on template dashboards).
      3. Add an override with an item pattern matching one of those items, e.g. My API endpoint_a Response Time, and a color.
      4. Link the template to a host and open the host dashboard (Monitoring > Hosts > Dashboards) with a user whose debug mode / error display is on.

      Result: 

      for every metric of the widget, the frontend shows:

      Undefined array key "hosts" [zabbix.php:17 → require_once() → ZBase->run() → ZBase->processRequest() → CController->run() → Widgets\SvgGraph\Actions\WidgetView->doAction() → Widgets\SvgGraph\Includes\CSvgGraphHelper::get() → Widgets\SvgGraph\Includes\CSvgGraphHelper::applyOverrides() in widgets/svggraph/includes/CSvgGraphHelper.php:493]
      Trying to access array offset on value of type null [... CSvgGraphHelper::applyOverrides() in widgets/svggraph/includes/CSvgGraphHelper.php:493]
      Trying to access array offset on value of type null [... CSvgGraphHelper::applyOverrides() in widgets/svggraph/includes/CSvgGraphHelper.php:493]
      preg_match(): Passing null to parameter #2 ($subject) of type string is deprecated [... CSvgGraphHelper::applyOverrides() → preg_match() in widgets/svggraph/includes/CSvgGraphHelper.php:493]

      The graph is drawn, but the overrides never match any metric, so their options (color etc.) are not applied.

      Expected:
      no PHP notices; the overrides apply to the matching items of the host, as in 7.4.

      Cause (release/8.0 and master, same line numbers as the 8.0.0 package):

      • ui/widgets/svggraph/actions/WidgetView.php:88-90 forces show_hostnames to SVG_GRAPH_LABELS_IN_HOSTNAMES_HIDE on template dashboards.
      • ui/widgets/svggraph/includes/CSvgGraphHelper.php:188 and :368 now request hosts only when host names are shown:
          'selectHosts' => $show_hostnames ? ['name'] : null,
          so on template dashboards the metrics have no hosts key.
      • CSvgGraphHelper::applyOverrides(), :461, sets the override host pattern to the name of the dashboard host when a template dashboard is viewed on a host:
          $override['hosts'] = [$override_host[0]['name']];
          and :493 compares it with $metric['hosts'][0]['name'], which does not exist.

      In release/7.4 'selectHosts' => ['name'] was unconditional, so this is a regression of 8.0 (the "show host names" option).

      Possible fix: request the host names whenever overrides are used (or always, as in 7.4), keeping show_hostnames only for the labels; or, on template dashboards viewed on a host, skip the host check in applyOverrides(), since every metric belongs to that host.

            Assignee:
            Aleksejs Brizgalovs
            Reporter:
            Sandro Bordacchini
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: