-
Notifications
You must be signed in to change notification settings - Fork 127
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Forms lost approver + Permission issue forms display after GLPI and forms update #997
Comments
Hi
There is already an issue about this, and a patch is pending. (#996) About your upgrade issue, please try to upgrade from 2.5.2 to the next release, and repeat until you reach the version 2.6.3 OR you observe the loss of information. This means you need to check after each upgrade if the approver is still there, and from which version it is lost. |
Hi Any feedback ? |
So again :) migration_to_2.6.0.log2018-06-14 21:37:59 [2@glpidev] sql-errors.log2018-06-14 21:38:01 [2@glpidev] SELECT COUNT(*) AS `cpt` FROM (SELECT DISTINCT
NULL AS `id`,
CONCAT('f_',`fanswer`.`id`) AS `display_id`,
`fanswer`.`id` AS `original_id`,
'PluginFormcreatorForm_Answer' AS `sub_itemtype`,
`f`.`name` AS `name`,
`fanswer`.`status` AS `status`,
`fanswer`.`request_date` AS `date_creation`,
`fanswer`.`request_date` AS `date_mod`,
`fanswer`.`entities_id` AS `entities_id`,
`fanswer`.`is_recursive` AS `is_recursive`,
`fanswer`.`requester_id` AS `requester_id`,
`fanswer`.`users_id_validator` AS `validator_id`,
`fanswer`.`comment` AS `comment`
FROM `glpi_plugin_formcreator_forms_answers` AS `fanswer`
LEFT JOIN `glpi_plugin_formcreator_forms` AS `f`
ON`f`.`id` = `fanswer`.`plugin_formcreator_forms_id`
LEFT JOIN `glpi_items_tickets` AS `itic`
ON `itic`.`items_id` = `fanswer`.`id`
AND `itic`.`itemtype` = 'PluginFormcreatorForm_Answer'
WHERE `fanswer`.`is_deleted` = '0'
GROUP BY `original_id`
HAVING COUNT(`itic`.`tickets_id`) != 1
UNION
SELECT DISTINCT
NULL AS `id`,
CONCAT('t_',`tic`.`id`) AS `display_id`,
`tic`.`id` AS `original_id`,
'Ticket' AS `sub_itemtype`,
`tic`.`name` AS `name`,
`tic`.`status` AS `status`,
`tic`.`date` AS `date_creation`,
`tic`.`date_mod` AS `date_mod`,
`tic`.`entities_id` AS `entities_id`,
0 AS `is_recursive`,
`tic`.`users_id_recipient` AS `requester_id`,
0 AS `validator_id`,
`tic`.`content` AS `comment`
FROM `glpi_tickets` AS `tic`
LEFT JOIN `glpi_items_tickets` AS `itic`
ON `itic`.`tickets_id` = `tic`.`id`
AND `itic`.`itemtype` = 'PluginFormcreatorForm_Answer'
WHERE `tic`.`is_deleted` = 0
GROUP BY `original_id`
HAVING COUNT(`itic`.`items_id`) <= 1) AS `issues` Error: Unknown column 'fanswer.users_id_validator' in 'field list' php-errors.logTest |
Armin83 is my work colleague. His statements are identical to mine. |
OK, so the issue is between 2.5.2 and 2.6.0. |
Hi Can you test this patch and feedback ? |
Hi, any fedback with the pach ? merge is postponed to 2.7.0 |
Should this patch also work on upgrade from 2.6.3 to 2.6.4(+patch) ? ps. sorry for late test. i was vacation.
|
Hi The patch changes the behavior if the upgrade process from a version less than 2.5.0 to 2.5.0. As long as the patch is applicable wthout conflict and you test it by upgrading the plugin from a version < 2.5.0, it will work. However, I need feedback to know if it works correctly. |
I'm also thinking about an issue where the plugin did not install a version information correctly. This may cause a bad starting point version for the upgrade process. Then I think I should continue investigation. Please show me the result of the following query, when you run it on a database before migration select * from glpi_configs where context='formcreator'; |
Upgrade Error 2.4.0 - 2.5.0
|
Before the update form 2.4.0 to 2.5.0 (empty set)
|
This value tells the upgrade code to upgrade from 2.5.0 to the next one but or seems the upgrade begins from a previous version anyway. I'll review and ask you for some other information. Have ready your database before upgrade to read some tables. |
with the patch i got this:
|
i take a snapshot - i can go back to glpi 9.1.2 database and version and can do the 2.5.0 update or higher each time you want. |
Hi @Armin83 I updated the patch. It seems the upgrade code for migration to 2.5.0 was incomplete. Please test this version of the patch and feedback. |
I got back to my backup 9.1.2 and 2.4.0 files from 2.5.0 and your patch. root@glpidev:/var/www/glpi/plugins/formcreator/install# cat ../../../files/_log/migration_to_2.5.0.log bug in browser this Fatal error: Uncaught Error: Call to undefined method DB::tableExists() in /var/www/glpi/plugins/formcreator/install/update_0.0_2.5.php:105 Stack trace: #0 /var/www/glpi/plugins/formcreator/install/update_0.0_2.5.php(44): plugin_formcreator_updateCategory_2_5(Object(Migration)) #1 /var/www/glpi/plugins/formcreator/install/install.php(41): plugin_formcreator_update_2_5(Object(Migration)) #2 /var/www/glpi/plugins/formcreator/hook.php(17): PluginFormcreatorInstall->upgrade(Object(Migration)) #3 /var/www/glpi/inc/plugin.class.php(664): plugin_formcreator_install() #4 /var/www/glpi/front/plugin.form.php(49): Plugin->install('6') #5 {main} thrown in /var/www/glpi/plugins/formcreator/install/update_0.0_2.5.php on line 105 |
While I fix the error, please have a look into the structure of the table glpi_plugin_formcreator_forms_answers. It should contain the column users_id_validator (I notice 1 second elapsed while upgrading the table, i guess the job you need is done). |
After review of the backtrace you just shared, it seems the error occurs before the code of the patch ran. I'm suspecting you forgot to upgrade glpi to 9.2.x before upgrading the plugin. Can you confirm glpi is upgraded first ? |
Yes because on first test i don't get a migration 2.5 log. Ibelieved my test source is wrong. i go back to 9.1.2 and checked if the plugin is 2.4.0. (it was) so i decided do only upgrade to 2.5.0 to see if it works. Test running |
|
I suggest you stay in the same upgrade as you initially described because I sometimes fix old upgrade steps when an issue like your's is reported. 2.6.3 is fine to have the best upgrade code. To find the fix it is important to strictly test with the same conditions as your initial problem. You may do things easier by upgrading GLPI files and db, then upgrade the files of the plugin and get a snapshot of the db. This snapshot is good to test several times to upgrade of the plugin while improving the patch. |
After review of the backtrace you just shared, it seems the error occurs before the code of the patch ran. I'm suspecting you forgot to upgrade glpi to 9.2.x before upgrading the plugin. Can you confirm glpi is upgraded first ? |
This error makes me think you have an inconsistency in GLPI. dbversion is a configuration value for glpi, not the plugin. It should match the version of GLPI, without the 3rd and last number. I added a fix for the warnings impacting target tickets. |
Ok i replaced the 2 files from #1059
|
I don't have users_id_validator before the update only after the update. I hope this was clear |
Indeed, I left a typo. This is fixed.
The patch adds the migration code in the good place, but I don't see why the column is missing when syncing the issues table. The sequence of upgrade steps looks ok to me :/
|
I think I found the right way now. Less problems than I believed, but a caveat in the upgrade of forms_answers. The patch should be applicable to 2.6.4 as it changes old upgrade code only. |
target 2.6.3 i got no error but super admin can't open.
but i believe there was a bug in a version so drop / restore again direct to 2.6.4 with patch. i got also no error and can see the forms. but in both cases the Form approver is missing
|
Hi Let's see if you experience an issue while populating the new columns user_id_validator and group_is_validator. Please do the following steps
After the upgrade you will have the new columns, but the old column validator_id will not be deleted. Let's compare the values of these columns. The value in validator_id must be found either in user_id_validator or group_id_validator. The code which moves the value from a column to an other is in install/update_2.5_2.6.php lines 72 to 82. $formTable = 'glpi_plugin_formcreator_forms';
$query = "UPDATE `$table`
INNER JOIN `$formTable` ON (`$table`.`plugin_formcreator_forms_id` = `$formTable`.`id`)
SET `users_id_validator` = 'validator_id'
WHERE `$formTable`.`validation_required` = '1'";
$DB->query($query) or plugin_formcreator_upgrade_error($migration);
$query = "UPDATE `$table`
INNER JOIN `$formTable` ON (`$table`.`plugin_formcreator_forms_id` = `$formTable`.`id`)
SET `groups_id_validator` = 'validator_id'
WHERE `$formTable`.`validation_required` = '2'";
$DB->query($query) or plugin_formcreator_upgrade_error($migration); You may use this queriy to check the values select validator_id, user_id_validator, group_id_validator
from glpi_plugin_formcreator_forms_answers as fa
inner join glpi_plugin_formcreator_forms as f on (f.id = fa.plugin_formcreator_forms_id)
where f.validation_required > 0 |
First. Typo :)
Next:
|
Nobody else matters? Everybody must have this bug In the set statement from install/update_2.5_2.6.php lines 72 to 82. |
Yes, sorry for the typos; I'm switching to an orthogonal keyboard with a temporary skin to switch later to orthogonal bépo (this requires to type stronger, and train muscular memory). Have a look to typematrix 2030 keyboards if you're curious. For a few months i'll have fingers fater tha never ;). Now we have the proof the following queries don't do their job $table = 'glpi_plugin_formcreator_forms_answers';
$formTable = 'glpi_plugin_formcreator_forms';
$query = "UPDATE `$table`
INNER JOIN `$formTable` ON (`$table`.`plugin_formcreator_forms_id` = `$formTable`.`id`)
SET `users_id_validator` = 'validator_id'
WHERE `$formTable`.`validation_required` = '1'";
$DB->query($query) or plugin_formcreator_upgrade_error($migration);
$query = "UPDATE `$table`
INNER JOIN `$formTable` ON (`$table`.`plugin_formcreator_forms_id` = `$formTable`.`id`)
SET `groups_id_validator` = 'validator_id'
WHERE `$formTable`.`validation_required` = '2'";
$DB->query($query) or plugin_formcreator_upgrade_error($migration); |
can you try to run one of them ? update glpi_plugin_formcreator_forms_answers
inner join glpi_plugin_formcreator_forms on glpi_plugin_formcreator_forms_answers.plugin_formcreator_forms_id = glpi_plugin_formcreator_forms.id
where glpi_plugin_formcreator_forms.validation_required=1 then see if some values moved to users_id_validator ? select validator_id, users_id_validator, groups_id_validator from glpi_plugin_formcreator_forms_answers as fa inner join glpi_plugin_formcreator_forms as f on (f.id = fa.plugin_formcreator_forms_id) where f.validation_required > 0; |
Yes - this works. Sorry i did not write it. I understand the structure at this moment and wrote the update. it works. I can see them. (browser) |
I cross posted with your comment #997 (comment) Good point. The error is indeed here. |
The PR is updated. Waiting for your feedback. It is strange noone fond this issue earlier. This shows necessity to continue the background task of writing unit tests. |
Cross post again...
Then I can submit for external review, then merge it. Thank you for your feedback and tries. |
Yes the patch works for do the upgrade from my old backup with old version. It looks good for me :) |
previous GLPI version: 9.1.2
previous forms Version: 2.5.2
GLPI version updated to version 9.2.3
Forms updated to 2.6.3
All forms created in the past have lost the form approver.
In addition, these forms can no longer be displayed with the "Super Admin" profile. This profile no longer has permissions for this.
In addition, there is the problem that within a ticket, the direct link to the form no longer works.
The text was updated successfully, but these errors were encountered: