UsageImpact stops on "Duplicate entry" when an asset has no infocom dates
まだ誰も着手していません。
評価
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 初心者へのやさしさ
- 70/100
調査の方向性
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分
- マージ済み PR(30日)
- 1
環境構築
このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- 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 1週間以上 初心者へのやさしさ 30/100
pluginsGLPI/carbon#392 ·
-
難易度 5/5 1週間以上 初心者へのやさしさ 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 日以内に返信