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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
### Fixed

- Fix generate associated item massive action
- Add safety guards in Generate item flow for invalid references and non-existent classes (GLPI 11 / PHP 8.3)
- Update locales


Expand Down
5 changes: 3 additions & 2 deletions inc/link.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,8 @@ public function showItemGenerationForm($params)
$row['template_name'] = "";
}

if (Toolbox::hasTrait($itemtype, AssignableItem::class)) {
// GLPI 11 safety: skip non-existent classes (e.g. uninstalled plugins like GenericObject)
if (class_exists($itemtype) && Toolbox::hasTrait($itemtype, AssignableItem::class)) {
$row['assignableitem'] = true;
if (!is_array($row['groups_id'])) {
$row['groups_id'] = $row['groups_id'] > 0 ? [$row['groups_id']] : [];
Expand All @@ -174,7 +175,7 @@ public function showItemGenerationForm($params)
'active_entities' => $_SESSION['glpiactiveentities'] ?? [],
'item_rows' => $item_rows,
'order_web_dir' => $order_web_dir,
'assignableitem' => Toolbox::hasTrait($itemtype, AssignableItem::class),
'assignableitem' => class_exists($itemtype) && Toolbox::hasTrait($itemtype, AssignableItem::class),
]);
return null;
}
Expand Down
9 changes: 8 additions & 1 deletion inc/reference.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,14 @@ public function checkIfTemplateExistsInEntity($detailID, $itemtype, $entity)
} else {
$row = $result->current();
$item = getItemForItemtype($itemtype);
$item->getFromDB($row["templates_id"]);
// GLPI 11 safety: custom asset classes may fail to resolve in HTTP context
// and templates_id may be 0 for entries created before plugin migration.
if ($item === false || empty($row["templates_id"])) {
return 0;
}
if (!$item->getFromDB($row["templates_id"])) {
return 0;
}
if ($item->getField('entities_id') == $entity
|| ($item->maybeRecursive()
&& $item->fields['is_recursive']
Expand Down