Skip to content

Commit 8b31647

Browse files
authored
fix(Object): fix warning (#430)
* fix(Object): fix warning * adapt changelog
1 parent 756aaec commit 8b31647

File tree

2 files changed

+17
-5
lines changed

2 files changed

+17
-5
lines changed

CHANGELOG.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,11 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
1111

1212
### Fixed
1313

14-
- Reverted performance optimization for GenericObject (#417) due to issues with object registration and broken options.
14+
- Prevent PHP warning about unknown option `itemdevicedrive_types` and `itemdevicecontrol_types` when registering type
15+
16+
### Fixed
1517

18+
- Reverted performance optimization for GenericObject (#417) due to issues with object registration and broken options.
1619

1720
## [2.14.12] - 2024-04-11
1821

inc/object.class.php

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ public static function registerType()
173173
PluginGenericobjectType::includeLocales($item->getObjectTypeName());
174174
PluginGenericobjectType::includeConstants($item->getObjectTypeName());
175175

176-
Plugin::registerClass($class, [
176+
$options = [
177177
"document_types" => $item->canUseDocuments(),
178178
"helpdesk_visible_types" => $item->canUseTickets(),
179179
"linkgroup_types" => isset($fields["groups_id"]),
@@ -203,9 +203,18 @@ public static function registerType()
203203
"itemdevicegraphiccard_types" => $item->canUseItemDevice(),
204204
"itemdevicemotherboard_types" => $item->canUseItemDevice(),
205205
"itemdevicecamera_types" => $item->canUseItemDevice(),
206-
"itemdevicedrive_types" => $item->canUseItemDevice(),
207-
"itemdevicecontrol_types" => $item->canUseItemDevice(),
208-
]);
206+
207+
];
208+
209+
$glpiVersion = new Plugin();
210+
$glpiVersion = $glpiVersion->getGlpiVersion();
211+
212+
if (version_compare($glpiVersion, "10.0.19", '>=')) {
213+
$options["itemdevicedrive_types"] = $item->canUseItemDevice();
214+
$options["itemdevicecontrol_types"] = $item->canUseItemDevice();
215+
}
216+
217+
Plugin::registerClass($class, $options);
209218

210219
if (plugin_genericobject_haveRight($class, READ)) {
211220
//Change url for adding a new object, depending on template management activation

0 commit comments

Comments
 (0)