GLPI 12: 11 reports fail with "Ocorreu um erro inesperado" (subquery params lost in QueryExpression, QueryUnion passed to request(), empty IN)
維護者通常 1 天內回覆
還沒有人認領這個 Issue。
評估
研究方向
Start with inc/inventory.class.php: the issue identifies seven QueryExpression percentage subqueries and two reports passing QueryUnion directly to $DB->request(). Then inspect the second request in inc/helpdeskplus.class.php for the empty category list in reportHgbarRespectedSlasByTopCategory. Reproduce the three failures on GLPI 12 and verify the bundled reports open without errors and their percentages match direct SQL counts.
由索引模型根據 Issue 內容生成。
描述
Description
With GLPI 12.0.1 and mreporting 1.11.0 / 1.11.1, 11 of the bundled reports end on the GLPI error page. We opened every report of the plugin (Helpdesk, Helpdesk advanced, Inventory, Tag): the Helpdesk and Tag reports work. The broken ones are 10 Inventory reports and 1 Helpdesk advanced report. There are three different causes, all related to GLPI 12 executing queries as prepared statements.
1. Percentage subquery loses its parameters (6 Inventory reports)
reportPie/HbarComputersByFabricant, reportPie/HbarComputersByType, reportHbarComputersByStatus, reportHbarPrintersByStatus:
Number of placeholders (6) in SQL statement does not match number of values (3).
The percentage is built as:
new QueryExpression("COUNT(*) * 100 / " . new QuerySubQuery($subquery, 'Percent'))
Casting the QuerySubQuery to a string keeps the ? placeholders of the subquery, but its values are not carried over, so the statement has more placeholders than values. In GLPI 12, QueryExpression has a third $values argument, so the parameters can be passed along:
$sub = new QuerySubQuery($subquery, 'Percent');
new QueryExpression('COUNT(*) * 100 / ' . $sub, null, $sub->getParams());
There are 7 occurrences in inc/inventory.class.php (same code in master).
2. QueryUnion passed directly to $DB->request() (4 Inventory reports)
reportPie/HbarComputersByAge, reportPie/HbarComputersByOS:
TypeError: DBmysqlIterator::execute(): Argument #1 ($criteria) must be of type array, Glpi\DBAL\QueryUnion given
inc/inventory.class.php:386 (computersByAge), inc/inventory.class.php:525 (computersByOS)
GLPI 12 only accepts an array here. Using the union as FROM works, as the core does (for example Lockedfield.php):
$query = new QueryUnion($queries);
$result = $DB->request(['FROM' => $query]);
These queries also contain the percentage subquery from point 1.
3. Empty IN when no ticket has an SLA (1 Helpdesk advanced report)
reportHgbarRespectedSlasByTopCategory:
RuntimeException: Empty IN are not allowed
inc/helpdeskplus.class.php (second $DB->request() of reportHgbarRespectedSlasByTopCategory)
When no category is selected and no ticket has an SLA, $categories is empty and is used as ITILCategory::getTable() . '.id' => $categories. Returning the empty result before the second query avoids the error, for example:
if (!$category && $categories === []) {
return ['labels2' => [$this->lcl_slaok => $this->lcl_slaok, $this->lcl_slako => $this->lcl_slako]];
}
Result
With these three changes applied locally on 1.11.1, all reports of the plugin open without error, nothing new is logged, and the percentages are the same as a direct SQL count (checked on "Computers by manufacturer").
Side note, not an error: in the Inventory reports the total used for the percentage (the subquery) does not filter is_deleted = 0, while the counted rows do. When items are in the trash, the percentages do not add up to 100 %.
Environment
- GLPI 12.0.1
- mreporting 1.11.0 and 1.11.1 (same code for these parts in
master) - PHP 8.4.27, MariaDB 11.8.6, Debian 13
- 主要語言
- PHP
- 星號
- 38
- 分支
- 44
- 平均合併
- 10 小時 52 分鐘
- 30 天內合併 PR
- 8
環境準備
這個專案沒有提供開發容器、Dockerfile 或貢獻指南,環境需要你自己搭建:先看它的 README,通用步驟見我們的新手貢獻指南。
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
相似的 Issue
-
難度 1/5 1 小時以內 新手友好度 82/100
pluginsGLPI/carbon#396 ·
-
[BUG] Bundle products lose their price in RSS feeds: getPrices() was removed可能已有人在做 @pcvelz 今天認領。 未關閉
難度 1/5 1 小時以內 新手友好度 90/100
OpenMage/magento-lts#5869 ·
維護者通常 2 天內回覆
-
難度 1/5 1-3 小時 新手友好度 85/100
modelcontextprotocol/php-sdk#746 ·
維護者通常 1 天內回覆
-
難度 1/5 1 小時以內 新手友好度 90/100
OpenGIS/waymark-wp#82 ·
-
bug
難度 2/5 1-3 小時 新手友好度 68/100
維護者通常 1 天內回覆