Skip to content

Feat: rename oversized containers from their edit form - #1248

Open
Rom1-B wants to merge 6 commits into
mainfrom
support_45901
Open

Rom1-B wants to merge 6 commits into
mainfrom
support_45901

Conversation

@Rom1-B

@Rom1-B Rom1-B commented Aug 21, 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

  • It fixes !45901
  • When a container's computed table name exceeds MySQL's 64-character limit, the plugin now disables it instead of crashing, and shows a rename form directly on the container's edit page.
  • Submitting a shorter name renames the container and reactivates it; if a table with matching data already exists under that name (e.g. after a version migration), its data is preserved instead of being replaced by an empty table.
  • plugins:fields:check_database now also reports container/item type pairs with no matching table, and tables with no matching container/item type pair.

Screenshots (if appropriate):

Comment thread inc/checkdatabasecommand.class.php
Comment thread inc/checkdatabasecommand.class.php
Comment thread inc/container.class.php
@Rom1-B
Rom1-B requested a review from stonebuzz August 24, 2026 09:56
@Rom1-B
Rom1-B requested review from Otijom and removed request for Otijom September 17, 2026 12:38
@Rom1-B
Rom1-B force-pushed the support_45901 branch 2 times, most recently from 96320bf to 1f9fcbe Compare September 22, 2026 11:17
Comment thread tests/Units/ContainerTest.php
Comment thread inc/container.class.php Outdated
Comment thread inc/container.class.php Outdated
Comment thread inc/container.class.php
@Rom1-B
Rom1-B requested a review from RomainLvr September 25, 2026 13:50
Comment thread inc/container.class.php Outdated
$itemtype = $item::class;
$containers = new self();
$founded_containers = $containers->find();
$founded_containers = $containers->find(['is_active' => 1]);

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.

preItemPurge() now skips every inactive container, not only oversized ones: purging an item attached to a manually disabled container leaves its rows behind in that container table (orphan data resurfacing if the container is re-enabled).

Comment thread inc/container.class.php
$claimed_orphans[] = $old_table;

if (countElementsInTable($old_table) > 0) {
$migration->renameTable($old_table, $new_table);

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.

If an orphan table is recovered for this container while a different table already exists under $new_table, GLPI's Migration::renameTable() silently returns for glpi_plugin_* tables (no exception). The container is then reactivated on the pre-existing $new_table, the recovered data stays in the orphan table, and the user still gets "existing data preserved". Reject the rename (or at least skip $data_preserved) when $DB->tableExists($new_table) and $new_table !== $old_table.

if ($new_table !== $old_table && $DB->tableExists($new_table)) {
    Session::AddMessageAfterRedirect(sprintf(__('Table %s already exists.', 'fields'), $new_table), false, ERROR);
    return false;
}

@Rom1-B
Rom1-B requested a review from stonebuzz September 30, 2026 06:09
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