Skip to content

Commit 9e4693d

Browse files
authored
Fix: FormCreator migration fails with sub entity (#1109)
* Fix: FormCreator migration fails with sub entity * changelog * fix tests
1 parent d5a09b6 commit 9e4693d

File tree

3 files changed

+25
-1
lines changed

3 files changed

+25
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
99

1010
- Fix prevent failure when attempting to delete an actor
1111
- Fix form `path` for `tab` `container`
12+
- Fix error during Forms migration when block is not on root entity
1213

1314
## [1.23.1] - 2025-11-20
1415

inc/questiontype.class.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,8 @@ private function getAvailableBlocks(): array
327327
{
328328
$field_container = new PluginFieldsContainer();
329329
$available_blocks = [];
330+
331+
$entity_restrict = isCommandLine() ? [] : getEntitiesRestrictCriteria(PluginFieldsContainer::getTable(), '', '', true);
330332
$result = $field_container->find([
331333
'is_active' => 1,
332334
'type' => 'dom',
@@ -335,7 +337,7 @@ private function getAvailableBlocks(): array
335337
['itemtypes' => ['LIKE', '%\"Change\"%']],
336338
['itemtypes' => ['LIKE', '%\"Problem\"%']],
337339
],
338-
] + getEntitiesRestrictCriteria(PluginFieldsContainer::getTable(), '', '', true), 'name');
340+
] + $entity_restrict, 'name');
339341
foreach ($result as $id => $data) {
340342
$available_blocks[$id] = $data['label'];
341343
}

tests/fixtures/formcreator.sql

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,27 @@
2626
-- -------------------------------------------------------------------------
2727
--
2828

29+
DROP TABLE IF EXISTS `glpi_plugin_formcreator_formanswers`;
30+
CREATE TABLE IF NOT EXISTS `glpi_plugin_formcreator_formanswers` (
31+
`id` int unsigned NOT NULL AUTO_INCREMENT,
32+
`name` varchar(255) NOT NULL DEFAULT '',
33+
`entities_id` int unsigned NOT NULL DEFAULT '0',
34+
`is_recursive` tinyint(1) NOT NULL DEFAULT '0',
35+
`plugin_formcreator_forms_id` int unsigned NOT NULL DEFAULT '0',
36+
`requester_id` int unsigned NOT NULL DEFAULT '0',
37+
`users_id_validator` int unsigned NOT NULL DEFAULT '0' COMMENT 'User in charge of validation',
38+
`groups_id_validator` int unsigned NOT NULL DEFAULT '0' COMMENT 'Group in charge of validation',
39+
`request_date` timestamp NULL,
40+
`status` int(11) NOT NULL DEFAULT '101',
41+
`comment` mediumtext,
42+
PRIMARY KEY (`id`),
43+
INDEX `plugin_formcreator_forms_id` (`plugin_formcreator_forms_id`),
44+
INDEX `entities_id_is_recursive` (`entities_id`, `is_recursive`),
45+
INDEX `requester_id` (`requester_id`),
46+
INDEX `users_id_validator` (`users_id_validator`),
47+
INDEX `groups_id_validator` (`groups_id_validator`)
48+
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ROW_FORMAT=DYNAMIC;
49+
2950
DROP TABLE IF EXISTS `glpi_plugin_formcreator_categories`;
3051
CREATE TABLE `glpi_plugin_formcreator_categories` (
3152
`id` int unsigned NOT NULL AUTO_INCREMENT,

0 commit comments

Comments
 (0)