From 714aa6df41c62a0ddfacbd8972c0a10fac222c49 Mon Sep 17 00:00:00 2001 From: Rom1-B <8530352+Rom1-B@users.noreply.github.com> Date: Thu, 3 Dec 2026 12:04:31 +0100 Subject: [PATCH] Fix: avoid SLA report crash, exclude trash from percentages --- CHANGELOG.md | 3 +++ inc/helpdeskplus.class.php | 12 +++++++++--- inc/inventory.class.php | 4 +++- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 355eb4bb..8d72c425 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/). - Faster dashboards and report pages: report configurations and rights are read once per page - Faster "Backlogs", "Computers by OS", "Tickets per service", "Ticket status by technician" and "Computers by entity" reports, with the same results - Fewer queries on every GLPI page and on the core statistics page +- Fix the "Tickets per SLA ordered by categories" report failing when no ticket has an SLA +- Fix a deprecation warning in the "Computer per age" report +- Fix percentages of the "Computers per manufacturer" and "Computers per type" reports counting computers in the trash ## [1.10.4] - 2026-11-04 diff --git a/inc/helpdeskplus.class.php b/inc/helpdeskplus.class.php index a477d988..bfcf198f 100644 --- a/inc/helpdeskplus.class.php +++ b/inc/helpdeskplus.class.php @@ -1102,6 +1102,15 @@ public function reportHgbarRespectedSlasByTopCategory($config = []) } } + $datas['labels2'] = [$this->lcl_slaok => $this->lcl_slaok, + $this->lcl_slako => $this->lcl_slako, + ]; + + // No ticket with an SLA: an empty IN would throw + if (!$category && $categories === []) { + return $datas; + } + $query = [ 'SELECT' => [ $this->criteria_select_sla, @@ -1139,9 +1148,6 @@ public function reportHgbarRespectedSlasByTopCategory($config = []) : $this->lcl_slako; $datas['datas'][$data['name']][$value] = $data['nb']; } - $datas['labels2'] = [$this->lcl_slaok => $this->lcl_slaok, - $this->lcl_slako => $this->lcl_slako, - ]; if (isset($datas['datas'])) { foreach ($datas['datas'] as &$data) { diff --git a/inc/inventory.class.php b/inc/inventory.class.php index 16a43f0c..4a52a3bc 100644 --- a/inc/inventory.class.php +++ b/inc/inventory.class.php @@ -154,6 +154,7 @@ public function computersByFabricant($config = []) ], 'WHERE' => array_merge( [ + Computer::getTable() . '.is_deleted' => 0, Computer::getTable() . '.is_template' => 0, Computer::getTable() . '.entities_id' => PluginMreportingCommon::formatWhereEntitiesArray($this->where_entities), ], @@ -239,6 +240,7 @@ public function computersByType($config = []) ], 'WHERE' => array_merge( [ + Computer::getTable() . '.is_deleted' => 0, Computer::getTable() . '.is_template' => 0, Computer::getTable() . '.entities_id' => PluginMreportingCommon::formatWhereEntitiesArray($this->where_entities), ], @@ -383,7 +385,7 @@ public function computersByAge($config = []) } $query = new QueryUnion($queries); - $result = $DB->request($query); + $result = $DB->request(['FROM' => $query]); foreach ($result as $computer) { $percent = round(floatval($computer['Percent']), 2);