Skip to content

Conversation

@Rom1-B
Copy link
Contributor

@Rom1-B Rom1-B commented Dec 18, 2025

Checklist before requesting a review

Please delete options that are not relevant.

  • I have read the CONTRIBUTING document.
  • I have performed a self-review of my code.
  • I have added tests that prove my fix is effective or that my feature works.
  • This change requires a documentation update.

Description

  • It fixes !40252
  • Here is a brief description of what this PR does

Avoid this error when migrating from genericobject to the core:

glpi.ERROR:   *** MySQL query error: Duplicate entry '10-Glpi\CustomAsset\otherAsset-2981-2' for key 'glpi_groups_items.unicity' (1062) in SQL query "INSERT INTO `glpi_groups_items` (`groups_id`, `itemtype`, `items_id`, `type`) VALUES ('10', 'Glpi\\CustomAsset\\otherAsset', '2981', '2')".
  Backtrace :
  ./src/DBmysql.php:398                              
  ./src/DBmysql.php:1356                             DBmysql->doQuery()
  ./src/CommonDBTM.php:781                           DBmysql->insert()
  ./src/CommonDBTM.php:1386                          CommonDBTM->addToDB()
  .../Glpi/Migration/AbstractPluginMigration.php:366 CommonDBTM->add()
  .../Migration/GenericobjectPluginMigration.php:857 Glpi\Migration\AbstractPluginMigration->importItem()
  .../Migration/GenericobjectPluginMigration.php:261 Glpi\Migration\GenericobjectPluginMigration->importObjects()
  .../Glpi/Migration/AbstractPluginMigration.php:139 Glpi\Migration\GenericobjectPluginMigration->processMigration()
  ...Migration/AbstractPluginMigrationCommand.php:88 Glpi\Migration\AbstractPluginMigration->execute()
  ./vendor/symfony/console/Command/Command.php:326   Glpi\Console\Migration\AbstractPluginMigrationCommand->execute()
  ./vendor/symfony/console/Application.php:1088      Symfony\Component\Console\Command\Command->run()
  ./src/Glpi/Console/Application.php:330             Symfony\Component\Console\Application->doRunCommand()
  ./vendor/symfony/console/Application.php:324       Glpi\Console\Application->doRunCommand()
  ./vendor/symfony/console/Application.php:175       Symfony\Component\Console\Application->doRun()
  ./bin/console:144                                  Symfony\Component\Console\Application->run()

And the console command displayed:

sudo -u www-data php bin/console migration:genericobject_plugin_to_core --dry-run

[==>-------------------------]   9%
Importing "other" objects...
> 2 assets definitions successfully imported.
> 109 "other models" dropdown entries successfully imported.
> 28 "other types" dropdown entries successfully imported.
> 2 "account types" dropdown entries successfully imported.
The migration failed.
🛈 The display preferences and saved searches related to a `genericobject` object type must be recreated manually.
x An unexpected error occurred
x Migration was aborted due to errors, all changes have been reverted.

Screenshots (if appropriate):

Copy link
Member

@cedric-anne cedric-anne left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not understand why a group would be created twice, unless maybe if the migration is replayed a second time.

Using reconciliation_criteria for specific imports is probably a better solution, to prevent catching every creation error.

diff --git a/src/Glpi/Migration/GenericobjectPluginMigration.php b/src/Glpi/Migration/GenericobjectPluginMigration.php
index d12d3400ef..7e4dc94ffd 100644
--- a/src/Glpi/Migration/GenericobjectPluginMigration.php
+++ b/src/Glpi/Migration/GenericobjectPluginMigration.php
@@ -857,6 +857,7 @@ class GenericobjectPluginMigration extends AbstractPluginMigration
                             $this->importItem(
                                 Group_Item::class,
                                 input: $group_input,
+                                reconciliation_criteria: $group_input
                             );
                         }
                     }
@@ -871,6 +872,7 @@ class GenericobjectPluginMigration extends AbstractPluginMigration
                         $this->importItem(
                             Domain_Item::class,
                             input: $domain_input,
+                            reconciliation_criteria: $domain_input
                         );
                     }

@Rom1-B Rom1-B requested a review from cedric-anne December 18, 2025 12:37
@cedric-anne cedric-anne merged commit 021ccfb into glpi-project:11.0/bugfixes Dec 18, 2025
7 of 9 checks passed
@cedric-anne cedric-anne added this to the 11.0.5 milestone Dec 18, 2025
@Rom1-B Rom1-B deleted the support_40252 branch December 19, 2025 06:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants