Skip to content

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

Merged
Rom1-B merged 7 commits into
mainfrom
fix_update_that_break_container_name_label_table
Jul 28, 2026
Merged

Fix(Migration): prevent container name corruption on partial update#1225
Rom1-B merged 7 commits into
mainfrom
fix_update_that_break_container_name_label_table

Conversation

@stonebuzz

@stonebuzz stonebuzz commented Jul 13, 2026

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

Replace #1221

Fixes : 43878, 45265

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_cintainers;
+----+---------+---------+--------------------------------+
| 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)

Screenshots (if appropriate):

Comment thread inc/container.class.php
@stonebuzz

Copy link
Copy Markdown
Contributor Author

Approved by !45265

Comment thread inc/container.class.php Outdated
Comment thread CHANGELOG.md Outdated
@Rom1-B
Rom1-B merged commit fb373de into main Jul 28, 2026
1 of 3 checks passed
@Rom1-B
Rom1-B deleted the fix_update_that_break_container_name_label_table branch July 28, 2026 06:12
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.

3 participants