Skip to content

Fix(Migration): prevent container name corruption on partial update#1221

Draft
stonebuzz wants to merge 1 commit into
mainfrom
fix_go_migration
Draft

Fix(Migration): prevent container name corruption on partial update#1221
stonebuzz wants to merge 1 commit into
mainfrom
fix_go_migration

Conversation

@stonebuzz

Copy link
Copy Markdown
Contributor

Checklist before requesting a review

Please delete options that are not relevant.

  • I have performed a self-review of my code.
  • I have added tests (when available) that prove my fix is effective or that my feature works.
  • I have updated the CHANGELOG with a short functional description of the fix or new feature.
  • This change requires a documentation update.

Description

During plugin installation when migrating containers from GenericObject to
CustomAsset, containers end up with a corrupted name field (e.g.
sixonefourfourthreesixtwozeroeight) and an empty label, causing a
subsequent MySQL error when the dynamic table name exceeds 64 characters.

Root cause

installBaseData calls update() with only id and itemtypes (no label key to update) see L249

prepareInputForUpdate() called prepareLabel() unconditionally, which:

  1. passed '' to getSystemNameFromLabel(), which fell back to
    random_int(0, mt_getrandmax()) for an empty name
  2. passed that integer through replaceIntByLetters(), spelling each
    digit out (6 1 4 4 3 6 2 0 0 8 => sixonefourfourthreesixtwozeroeight)

State before migration

mysql> SELECT id, name, label, itemtypes FROM glpi_plugin_fields_c
+----+---------+---------+--------------------------------+
| id | name | label | itemtypes |
+----+---------+---------+--------------------------------+
| 3 | contain | contain | ["PluginGenericobjectContain"] |
+----+---------+---------+--------------------------------+

State after migration (buggy)

+----+------------------------------------+-------+-------------------------------------+
| id | name | label | itemtypes
+----+------------------------------------+-------+-------------------------------------+
| 3 | sixonefourfourthreesixtwozeroeight | | ["Glpi\CustomA
+----+------------------------------------+-------+-------------------------------------+

This triggers:

RuntimeException: MySQL query error: Identifier name
'glpi_plugin_fields_glpicustomassetcontainassetsixonefourfourthree
is too long (1059)

@stonebuzz stonebuzz self-assigned this Jul 6, 2026
@stonebuzz stonebuzz marked this pull request as draft July 6, 2026 09:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant