Skip to content

Commit 65c461a

Browse files
committed
fix(fields): preveint fatal error when inconsistency found in DB
log the error Signed-off-by: Thierry Bugier <tbugier@teclib.com>
1 parent 0529a4e commit 65c461a

File tree

1 file changed

+17
-6
lines changed

1 file changed

+17
-6
lines changed

inc/fields.class.php

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -186,12 +186,23 @@ public static function isVisible(PluginFormcreatorConditionnableInterface $item,
186186
return self::$visibility[$itemtype][$itemId];
187187
}
188188
if (count($conditions) < 1) {
189-
if ($item->fields['show_rule'] == PluginFormcreatorCondition::SHOW_RULE_HIDDEN) {
190-
self::$visibility[$itemtype][$itemId] = false;
191-
return self::$visibility[$itemtype][$itemId];
192-
} else if ($item->fields['show_rule'] == PluginFormcreatorCondition::SHOW_RULE_SHOWN) {
193-
self::$visibility[$itemtype][$itemId] = true;
194-
return self::$visibility[$itemtype][$itemId];
189+
switch ($item->fields['show_rule']) {
190+
case PluginFormcreatorCondition::SHOW_RULE_HIDDEN:
191+
self::$visibility[$itemtype][$itemId] = false;
192+
return self::$visibility[$itemtype][$itemId];
193+
break;
194+
195+
case PluginFormcreatorCondition::SHOW_RULE_SHOWN:
196+
self::$visibility[$itemtype][$itemId] = true;
197+
return self::$visibility[$itemtype][$itemId];
198+
break;
199+
200+
default:
201+
// This should not happen : inconsistency in the database
202+
Toolbox::logError("Inconsistency detected in conditions: show rule set but no condition found, $itemtype ID=$itemId");
203+
self::$visibility[$itemtype][$itemId] = $getParentVisibility();
204+
return self::$visibility[$itemtype][$itemId];
205+
break;
195206
}
196207
}
197208

0 commit comments

Comments
 (0)