Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).

## [UNRELEASED]

### Fixed

- Fix migration abort when a GenericObject container name produces a table name exceeding MySQL's 64-character limit after conversion to GlpiCustomAsset.

## [1.24.0] - 2026-04-16

### Added
Expand Down
26 changes: 18 additions & 8 deletions inc/container.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -209,8 +209,9 @@ public static function installBaseData(Migration $migration, $version)
$container_class = new self();
foreach ($result as $container) {
self::generateTemplate($container);
$container_name = $container['name'];
foreach (json_decode((string) $container['itemtypes']) as $itemtype) {
$classname = self::getClassname($itemtype, $container["name"]);
$classname = self::getClassname($itemtype, $container['name']);
// prevent usage of plugin class if not loaded
if (!class_exists($classname)) {
continue;
Expand All @@ -223,20 +224,29 @@ public static function installBaseData(Migration $migration, $version)
&& isset($migration_genericobject_itemtype[$itemtype])
&& str_contains($old_table, 'glpi_plugin_fields_plugingenericobject' . $migration_genericobject_itemtype[$itemtype]['genericobject_name'])
) {
$new_table = str_replace('plugingenericobject' . $migration_genericobject_itemtype[$itemtype]['genericobject_name'], 'glpicustomasset' . strtolower($migration_genericobject_itemtype[$itemtype]['name']), $old_table);
$new_itemtype = $migration_genericobject_itemtype[$itemtype]['itemtype'];
// Limit table names to 64 chars (MySQL limit)
while (strlen(getTableForItemType(self::getClassname($new_itemtype, $container_name))) > 64) {
$container_name = substr((string) $container_name, 0, -1);
}

$new_table = getTableForItemType(self::getClassname($new_itemtype, $container_name));
$migration->renameTable($old_table, $new_table);
}
}

// Update old genericobject itemtypes in container
$map = array_column($migration_genericobject_itemtype, 'itemtype', 'genericobject_itemtype');
$itemtypes = strtr($container['itemtypes'], $map);
$container_class->update(
[
'id' => $container['id'],
'itemtypes' => $itemtypes,
],
);
$update_data = [
'id' => $container['id'],
'itemtypes' => $itemtypes,
];
if ($container_name !== $container['name']) {
$update_data['name'] = $container_name;
}

$container_class->update($update_data);
}
} else {
throw new RuntimeException(
Expand Down