diff --git a/CHANGELOG.md b/CHANGELOG.md index 8641b0e0..3e6f773a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). - Fix prevent failure when attempting to delete an actor - Fix form `path` for `tab` `container` +- Fix error during Forms migration when block is not on root entity ## [1.23.1] - 2025-11-20 diff --git a/inc/questiontype.class.php b/inc/questiontype.class.php index 36e32d02..a4558832 100644 --- a/inc/questiontype.class.php +++ b/inc/questiontype.class.php @@ -327,6 +327,8 @@ private function getAvailableBlocks(): array { $field_container = new PluginFieldsContainer(); $available_blocks = []; + + $entity_restrict = isCommandLine() ? [] : getEntitiesRestrictCriteria(PluginFieldsContainer::getTable(), '', '', true); $result = $field_container->find([ 'is_active' => 1, 'type' => 'dom', @@ -335,7 +337,7 @@ private function getAvailableBlocks(): array ['itemtypes' => ['LIKE', '%\"Change\"%']], ['itemtypes' => ['LIKE', '%\"Problem\"%']], ], - ] + getEntitiesRestrictCriteria(PluginFieldsContainer::getTable(), '', '', true), 'name'); + ] + $entity_restrict, 'name'); foreach ($result as $id => $data) { $available_blocks[$id] = $data['label']; } diff --git a/tests/fixtures/formcreator.sql b/tests/fixtures/formcreator.sql index 2c4ef61f..e5f4ee0c 100644 --- a/tests/fixtures/formcreator.sql +++ b/tests/fixtures/formcreator.sql @@ -26,6 +26,27 @@ -- ------------------------------------------------------------------------- -- +DROP TABLE IF EXISTS `glpi_plugin_formcreator_formanswers`; +CREATE TABLE IF NOT EXISTS `glpi_plugin_formcreator_formanswers` ( + `id` int unsigned NOT NULL AUTO_INCREMENT, + `name` varchar(255) NOT NULL DEFAULT '', + `entities_id` int unsigned NOT NULL DEFAULT '0', + `is_recursive` tinyint(1) NOT NULL DEFAULT '0', + `plugin_formcreator_forms_id` int unsigned NOT NULL DEFAULT '0', + `requester_id` int unsigned NOT NULL DEFAULT '0', + `users_id_validator` int unsigned NOT NULL DEFAULT '0' COMMENT 'User in charge of validation', + `groups_id_validator` int unsigned NOT NULL DEFAULT '0' COMMENT 'Group in charge of validation', + `request_date` timestamp NULL, + `status` int(11) NOT NULL DEFAULT '101', + `comment` mediumtext, + PRIMARY KEY (`id`), + INDEX `plugin_formcreator_forms_id` (`plugin_formcreator_forms_id`), + INDEX `entities_id_is_recursive` (`entities_id`, `is_recursive`), + INDEX `requester_id` (`requester_id`), + INDEX `users_id_validator` (`users_id_validator`), + INDEX `groups_id_validator` (`groups_id_validator`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ROW_FORMAT=DYNAMIC; + DROP TABLE IF EXISTS `glpi_plugin_formcreator_categories`; CREATE TABLE `glpi_plugin_formcreator_categories` ( `id` int unsigned NOT NULL AUTO_INCREMENT,