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..e40963d0 100644 --- a/inc/questiontype.class.php +++ b/inc/questiontype.class.php @@ -380,7 +380,15 @@ private function getAvailableBlocks(): array $field_container = new PluginFieldsContainer(); $available_blocks = []; + // No session and not CLI: return early to avoid invalid SQL criterion from + // getEntitiesRestrictCriteria() (returns entities_id = '' on integer column, + // producing MySQL warning 1292). Consistent with the guard in setup.php. + if (!Session::getLoginUserID() && !isCommandLine()) { + return $available_blocks; + } + $entity_restrict = isCommandLine() ? [] : getEntitiesRestrictCriteria(PluginFieldsContainer::getTable(), '', '', true); + $result = $field_container->find([ 'is_active' => 1, 'type' => 'dom',