Skip to content

Commit 24404ce

Browse files
committed
Apply suggestions
1 parent ecf1c25 commit 24404ce

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

inc/questiontype.class.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,17 @@ private function getAvailableBlocks(): array
380380
$field_container = new PluginFieldsContainer();
381381
$available_blocks = [];
382382

383-
$entity_restrict = (isCommandLine() || !Session::getLoginUserID()) ? [] : getEntitiesRestrictCriteria(PluginFieldsContainer::getTable(), '', '', true);
383+
$entity_restrict = isCommandLine() ? [] : getEntitiesRestrictCriteria(PluginFieldsContainer::getTable(), '', '', true);
384+
385+
// If entity restriction contains an empty string value, it means no valid session
386+
// is active. Running the query would produce a MySQL
387+
// warning (1292: Truncated incorrect DECIMAL value)
388+
foreach ($entity_restrict as $criterion) {
389+
if (is_array($criterion) && in_array('', $criterion, true)) {
390+
return $available_blocks;
391+
}
392+
}
393+
384394
$result = $field_container->find([
385395
'is_active' => 1,
386396
'type' => 'dom',

0 commit comments

Comments
 (0)