From b882743d4e9c185a8758f3d866261e25e180df84 Mon Sep 17 00:00:00 2001 From: RomainLvr Date: Mon, 13 Apr 2026 11:19:27 +0200 Subject: [PATCH 1/4] Fix - Avoid SQL warning when no user session is active during plugin init --- inc/questiontype.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inc/questiontype.class.php b/inc/questiontype.class.php index 1a8e0b6b..1cd7d63f 100644 --- a/inc/questiontype.class.php +++ b/inc/questiontype.class.php @@ -380,7 +380,7 @@ private function getAvailableBlocks(): array $field_container = new PluginFieldsContainer(); $available_blocks = []; - $entity_restrict = isCommandLine() ? [] : getEntitiesRestrictCriteria(PluginFieldsContainer::getTable(), '', '', true); + $entity_restrict = (isCommandLine() || !Session::getLoginUserID()) ? [] : getEntitiesRestrictCriteria(PluginFieldsContainer::getTable(), '', '', true); $result = $field_container->find([ 'is_active' => 1, 'type' => 'dom', From ecf1c25d3046295fc0b4195fe674fb772da36660 Mon Sep 17 00:00:00 2001 From: RomainLvr Date: Mon, 13 Apr 2026 11:21:16 +0200 Subject: [PATCH 2/4] Update CHANGELOG --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index f1418224..3193f59b 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 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 From 24404ce37a67a14e9aa197f997dc586d033bf410 Mon Sep 17 00:00:00 2001 From: RomainLvr Date: Wed, 15 Apr 2026 11:43:00 +0200 Subject: [PATCH 3/4] Apply suggestions --- inc/questiontype.class.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/inc/questiontype.class.php b/inc/questiontype.class.php index 1cd7d63f..6945955d 100644 --- a/inc/questiontype.class.php +++ b/inc/questiontype.class.php @@ -380,7 +380,17 @@ private function getAvailableBlocks(): array $field_container = new PluginFieldsContainer(); $available_blocks = []; - $entity_restrict = (isCommandLine() || !Session::getLoginUserID()) ? [] : getEntitiesRestrictCriteria(PluginFieldsContainer::getTable(), '', '', true); + $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', From 8e82d3657141035e06ef398099f851f189b7e96e Mon Sep 17 00:00:00 2001 From: RomainLvr Date: Thu, 16 Apr 2026 10:15:42 +0200 Subject: [PATCH 4/4] Apply suggestions --- inc/questiontype.class.php | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/inc/questiontype.class.php b/inc/questiontype.class.php index 6945955d..e40963d0 100644 --- a/inc/questiontype.class.php +++ b/inc/questiontype.class.php @@ -380,17 +380,15 @@ private function getAvailableBlocks(): array $field_container = new PluginFieldsContainer(); $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; - } + // 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',