diff --git a/CHANGELOG.md b/CHANGELOG.md index 4b2981a9..2fabe71d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ### Fixed +- Fix SQL warning when no user session is active during plugin init - Fix text area fields alignment - Fix error when submitting a form with an hidden question of type `Field` - Fixed a bug where a field was deleted when at least one question in a form was linked to another field diff --git a/inc/questiontype.class.php b/inc/questiontype.class.php index 1a8e0b6b..6945955d 100644 --- a/inc/questiontype.class.php +++ b/inc/questiontype.class.php @@ -381,6 +381,16 @@ private function getAvailableBlocks(): array $available_blocks = []; $entity_restrict = isCommandLine() ? [] : getEntitiesRestrictCriteria(PluginFieldsContainer::getTable(), '', '', true); + + // If entity restriction contains an empty string value, it means no valid session + // is active. Running the query would produce a MySQL + // warning (1292: Truncated incorrect DECIMAL value) + foreach ($entity_restrict as $criterion) { + if (is_array($criterion) && in_array('', $criterion, true)) { + return $available_blocks; + } + } + $result = $field_container->find([ 'is_active' => 1, 'type' => 'dom',