Conversation
a00e318 to
3eb87f1
Compare
96320bf to
1f9fcbe
Compare
| $itemtype = $item::class; | ||
| $containers = new self(); | ||
| $founded_containers = $containers->find(); | ||
| $founded_containers = $containers->find(['is_active' => 1]); |
There was a problem hiding this comment.
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).
| $claimed_orphans[] = $old_table; | ||
|
|
||
| if (countElementsInTable($old_table) > 0) { | ||
| $migration->renameTable($old_table, $new_table); |
There was a problem hiding this comment.
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;
}505470f to
bd5fca3
Compare
Checklist before requesting a review
Please delete options that are not relevant.
Description
plugins:fields:check_databasenow also reports container/item type pairs with no matching table, and tables with no matching container/item type pair.Screenshots (if appropriate):