Skip to content

Commit

Permalink
fix(fields): preveint fatal error when inconsistency found in DB
Browse files Browse the repository at this point in the history
log the error

Signed-off-by: Thierry Bugier <tbugier@teclib.com>
  • Loading branch information
btry committed Aug 18, 2021
1 parent 0529a4e commit 65c461a
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions inc/fields.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -186,12 +186,23 @@ public static function isVisible(PluginFormcreatorConditionnableInterface $item,
return self::$visibility[$itemtype][$itemId];
}
if (count($conditions) < 1) {
if ($item->fields['show_rule'] == PluginFormcreatorCondition::SHOW_RULE_HIDDEN) {
self::$visibility[$itemtype][$itemId] = false;
return self::$visibility[$itemtype][$itemId];
} else if ($item->fields['show_rule'] == PluginFormcreatorCondition::SHOW_RULE_SHOWN) {
self::$visibility[$itemtype][$itemId] = true;
return self::$visibility[$itemtype][$itemId];
switch ($item->fields['show_rule']) {
case PluginFormcreatorCondition::SHOW_RULE_HIDDEN:
self::$visibility[$itemtype][$itemId] = false;
return self::$visibility[$itemtype][$itemId];
break;

case PluginFormcreatorCondition::SHOW_RULE_SHOWN:
self::$visibility[$itemtype][$itemId] = true;
return self::$visibility[$itemtype][$itemId];
break;

default:
// This should not happen : inconsistency in the database
Toolbox::logError("Inconsistency detected in conditions: show rule set but no condition found, $itemtype ID=$itemId");
self::$visibility[$itemtype][$itemId] = $getParentVisibility();
return self::$visibility[$itemtype][$itemId];
break;
}
}

Expand Down

0 comments on commit 65c461a

Please sign in to comment.