Skip to content

feat(migration): add type renaming to resolve native asset name conflicts - #479

Merged
stonebuzz merged 17 commits into
mainfrom
ticket42658
Aug 10, 2026
Merged

feat(migration): add type renaming to resolve native asset name conflicts#479
stonebuzz merged 17 commits into
mainfrom
ticket42658

Conversation

@Rom1-B

@Rom1-B Rom1-B commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

  • 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.
  • This change requires a documentation update.

Description

  • It fixes !42658
  • It is not possible to migrate an asset from the genericobject plugin if its name is similar to an asset in the GLPI core. This fix allows users to rename an asset so they can continue the migration.

Screenshots (if appropriate):

Conflict:
image

Migrate
image

@Rom1-B
Rom1-B requested a review from stonebuzz July 6, 2026 12:27
@Rom1-B Rom1-B changed the title Ticket42658 feat(migration): add type renaming to resolve native asset name conflicts Jul 6, 2026
Comment thread inc/type.class.php Outdated
Co-authored-by: Stanislas <skita@teclib.com>
@Rom1-B
Rom1-B requested a review from stonebuzz July 13, 2026 11:36

@stonebuzz stonebuzz left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Something doesn't seem to be working correctly in the renaming process.

Let's take the KCM object as an example:

Image

I want to rename it to KVM.

After saving the change, GLPI displays a success message indicating that the operation completed successfully:

Image

However, after refreshing the page, I can see that the object has not actually been renamed and is still displayed as KCM.

I then retry the exact same operation, and this time it succeeds:

Image

The object is now correctly renamed to KVM:

Image

It looks like the first attempt returns a success message even though the rename is not actually applied. The change only takes effect after performing the exact same operation a second time.

@stonebuzz

Copy link
Copy Markdown
Contributor

If a plugin (in this case, Fields) references these objects, it breaks the migration process.

Traitement du plugin « fields »...
Installation des tables MySQL

In DBmysql.php line 417:
                                                                                                                                                                 
  MySQL query error: Table 'sopra.glpi_plugin_genericobject_kcms' doesn't exist (1146) in SQL query "SHOW COLUMNS FROM `glpi_plugin_genericobject_kcms`". 

Comment thread inc/type.class.php Outdated

@stonebuzz stonebuzz left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Hello,

It appears that the foreign keys associated with the renamed GenericObject objects were not renamed accordingly.

This seems to match the issue described in the following support ticket:
https://support.teclib.com/front/ticket.form.php?id=42658

@Rom1-B
Rom1-B requested a review from stonebuzz July 17, 2026 07:39
@stonebuzz

Copy link
Copy Markdown
Contributor

waiting customer feedback

@Rom1-B
Rom1-B requested a review from MyvTsv July 20, 2026 06:30
data-counter-target="{{ modal_id }}-counter"
data-warning-target="{{ modal_id }}-length-warning"
data-result-target="{{ modal_id }}-result"
oninput="glpiGenericobjectUpdateCounter(this)"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

oninput (line 259) triggers a fetch request on every keystroke without debounce. Add a ~300 ms debounce to glpiGenericobjectUpdateCounter to avoid a burst of requests during fast typing.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done

Comment on lines +253 to +254
pattern="[a-zA-Z][a-zA-Z0-9]*"
maxlength="{{ constant('PluginGenericobjectType::MAX_TYPE_NAME_LENGTH') }}"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

maxlength is set to MAX_TYPE_NAME_LENGTH (25), which caps raw input characters. System names expand digits to words (1one), so a 25-char input like a111… produces a system name far longer than 25. The AJAX counter shows the real length, but maxlength gives false assurance — the form submits successfully, then the server rejects it with no inline feedback.

The simplest solution would be to ban numbers and use only letters when renaming.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The real length is already validated both live (counter/warning turn red before you hit 25) and server-side (renameType() rejects and shows an explicit error message if you submit past the limit anyway), so there's no silent failure here. maxlength is just a soft cap, not the source of truth.

@Rom1-B
Rom1-B requested a review from stonebuzz August 10, 2026 11:31
@stonebuzz
stonebuzz merged commit fe332d3 into main Aug 10, 2026
3 checks passed
@stonebuzz
stonebuzz deleted the ticket42658 branch August 10, 2026 12:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants