diff --git a/ajax/showfields.php b/ajax/showfields.php index 2540f54eb..d514c0553 100644 --- a/ajax/showfields.php +++ b/ajax/showfields.php @@ -58,6 +58,9 @@ try { $visibility = PluginFormcreatorFields::updateVisibility($_POST); } catch (Exception $e) { + echo json_encode([ + 'error' => $e->getMessage(), + ]); http_response_code(500); exit(); } diff --git a/inc/fields.class.php b/inc/fields.class.php index fc1552de9..5a6be7253 100644 --- a/inc/fields.class.php +++ b/inc/fields.class.php @@ -140,7 +140,8 @@ public static function isVisible(PluginFormcreatorConditionnableInterface $item, /** @var CommonDBTM $item */ $itemtype = get_class($item); $itemId = $item->getID(); - if (!isset(self::$visibility[$itemtype][$itemId])) { + + if (!isset(self::$visibility[$itemtype]) || !array_key_exists($itemId, self::$visibility[$itemtype])) { self::$visibility[$itemtype][$itemId] = null; } else if (self::$visibility[$itemtype][$itemId] !== null) { return self::$visibility[$itemtype][$itemId];