UsageImpact stops on "Duplicate entry" when an asset has no infocom dates
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 70/100
Direzione di ricerca
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.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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
- Lingua principale
- PHP
- Stelle
- 5
- Fork
- 7
- Merge medio
- 2h 26m
- PR unite (30g)
- 1
Preparare l'ambiente
Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di pluginsGLPI/carbon
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 82/100
pluginsGLPI/carbon#396 ·
-
good first issue
Difficoltà 2/5 1-3 ore Idoneità per principianti 63/100
pluginsGLPI/carbon#239 ·
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 56/100
pluginsGLPI/carbon#397 ·
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 30/100
pluginsGLPI/carbon#392 ·
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 25/100
pluginsGLPI/carbon#391 ·
Tutte le issue di pluginsGLPI/carbon
Issue simili
-
[BUG] Bundle products lose their price in RSS feeds: getPrices() was removedForse già presa @pcvelz l’ha presa oggi. Aperta
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 90/100
OpenMage/magento-lts#5869 ·
I maintainer di solito rispondono entro 2 giorni
-
Difficoltà 1/5 1-3 ore Idoneità per principianti 85/100
modelcontextprotocol/php-sdk#746 ·
I maintainer di solito rispondono entro 1 giorno
-
Map Info Window ButtonsAperta
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 90/100
OpenGIS/waymark-wp#82 ·
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
I maintainer di solito rispondono entro 1 giorno
-
claude
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
sprain/sprainocchio#39 ·
I maintainer di solito rispondono entro 1 giorno