UsageImpact stops on "Duplicate entry" when an asset has no infocom dates
还没有人认领这个 Issue。
评估
调研方向
Start by reading Toolbox::getOldestAssetDate(), findTemporalGapsInTable(), and AbstractAsset::evaluateItem(), which the issue identifies as the path that produces the duplicate entry. Reproduce with an asset that has no use, delivery, or buy date and whose creation date includes a time; then verify that repeated UsageImpact runs complete without a duplicate key error and continue calculating later assets.
由索引模型根据 Issue 内容生成。
描述
GLPI version: 11.0.11
Plugin version: 1.3.1 (same code in 1.4.0)
Bug description
When an asset has no use, delivery or buy date in its financial information, Toolbox::getOldestAssetDate() returns date_creation with its time part, for example 2026-04-27 15:44:40. Only infocom dates are reset to midnight.
findTemporalGapsInTable() then filters on date >= '2026-04-27 15:44:40', so the row already calculated for 2026-04-27 00:00:00 falls outside the window and the first day is seen as a gap. AbstractAsset::evaluateItem() sets the cursor back to midnight and inserts that day again, which fails on the unicity key.
The exception is not caught per asset: the whole UsageImpact run ends in "Execution error", and every asset after this one is no longer calculated. On our instance the task failed every day for ten days, with 22 assets in this case.
Relevant log output
[2026-11-10 08:58:18] glpi.ERROR: *** Caught RuntimeException: MySQL query error: Duplicate entry 'Computer-16576-2026-04-27 00:00:00' for key 'unicity' (1062) in SQL query "INSERT INTO `glpi_plugin_carbon_carbonemissions` ...
Steps to reproduce
- Create a computer with a usage profile and a known power, with no use, delivery or buy date. Its
date_creationhas a time part. - Run UsageImpact: history is calculated from the creation day.
- Run UsageImpact again the next day: duplicate entry on the creation day, the task is in error.
Anything else?
Workaround: set a use date on the asset. A fix could be to reset the date returned by getOldestAssetDate() to midnight in every case, and to catch the error per asset so that one asset does not block the others.
Laurent Tison, Afnic
- 主要语言
- PHP
- 星标
- 5
- 派生
- 7
- 平均合并
- 2 小时 26 分钟
- 30 天内合并 PR
- 1
环境准备
这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
pluginsGLPI/carbon 的其他 Issue
-
难度 1/5 1 小时以内 新手友好度 82/100
pluginsGLPI/carbon#396 ·
-
good first issue
难度 2/5 1-3 小时 新手友好度 63/100
pluginsGLPI/carbon#239 ·
-
难度 3/5 1-2 天 新手友好度 56/100
pluginsGLPI/carbon#397 ·
-
难度 5/5 一周以上 新手友好度 30/100
pluginsGLPI/carbon#392 ·
-
难度 5/5 一周以上 新手友好度 25/100
pluginsGLPI/carbon#391 ·
查看 pluginsGLPI/carbon 的全部 Issue
相似的 Issue
-
[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 天内回复
-
claude
难度 2/5 1-3 小时 新手友好度 76/100
sprain/sprainocchio#39 ·
维护者通常 1 天内回复