Skip to content

Commit de45dd9

Browse files
committed
verifying that the item implements AssignableItem interface before unsetting the groups_id field
1 parent 8ebf7a7 commit de45dd9

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

inc/commoninjectionlib.class.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
* -------------------------------------------------------------------------
2929
*/
3030
use Glpi\Exception\Http\HttpException;
31+
use Glpi\Features\AssignableItem;
3132

3233
use function Safe\preg_match;
3334
use function Safe\preg_replace;
@@ -965,7 +966,7 @@ private function setValueForItemtype($itemtype, $field, $value, $fromdb = false)
965966
if (isForeignKeyField($field) || (str_contains($field, 'is_')) || (method_exists($injectionClass, 'isNullable') && !$injectionClass->isNullable($field))) {
966967
//If the field concernes groupds, unseting it instead of setting it to 0 in order to avoid associating the item to a non existing group (id 0)
967968
$group_fields = ['groups_id_tech', 'groups_id', 'groups_id_normal'];
968-
if (in_array($field, $group_fields)) {
969+
if (in_array($field, $group_fields) && Toolbox::hasTrait($itemtype, AssignableItem::class)) {
969970
unset($this->values[$itemtype][$field]);
970971
} else {
971972
// If the field is an id, we set it to 0

0 commit comments

Comments
 (0)