pluginsGLPI / customfields

customfields plugin for GLPI
GNU General Public License v2.0
13 stars 4 forks source link

Impossible to activate the plugin #35

Closed micter59 closed 10 years ago

micter59 commented 10 years ago

Hello,

I've just tested the "1.5-bugfixes" branch, and I can go a step further. Now GPLI let me install it. But when I try to activate the plugin, here's the error message I've got at the screen : Duplicate column name 'unique'

Then I've no access to the plugin configuration anymore. I mean the page "Configuration > Plugins". So I can't configure any plugin anymore :-(

Thank you for your job.

Michaël customfieldsactivationerror

dethegeek commented 10 years ago

Damn !

Please have a look in the apache's error log. There must be an error when you open the plugins page.

Please tell me also from which version you are migrating.

dethegeek commented 10 years ago

Please show me the column names and types you find in the table "glpi_plugin_customfields_fields". I think you already have a column named "unique".

When you try to upgrade the plugin, do you restore your database to a snapshot done before any attempt to upgrade the plugin ?

micter59 commented 10 years ago

The GLPI's version is 0.84.2, and the former customfields plugin was in the 1.3 version. Unfortunately there's no apache error log ! I can't be absolutely certain, but when I restored the database, it was to a snapshot with no attempt to upgrade the plugin. columns

dethegeek commented 10 years ago

Please execute the following query

SELECT * FROM glpi_plugin_customfields_itemtypes WHERE itemtype = "Version"

and tell me the rows it returns. This is the version of the database model used by the plugin.

micter59 commented 10 years ago

Here's the result of the query :

resultatrequete

dethegeek commented 10 years ago

OK, I think you tried 9 ou 10 times to upgrade. It seems some code runs twice in the upgrade process. I already noticed this as a possible behavior. I'm a bit busy now but I'll search for a fix in a few days.

dethegeek commented 10 years ago

I think you got lots of duplicates in your table : each itemtype should appear only once. Restore your database and check you have no duplicate (the values in the column itemtype should be unique)

I fixed #36 just now and it should help solving your issue. I need some more work to solve your issue.

micter59 commented 10 years ago

This is an exact copy of my production database. I'll look for an old backup, before upgrading GLPI to 0.84, and see if these lines are there. Is it a problem if I just delete these lines directly in the database ? Which one should I keep ?

dethegeek commented 10 years ago

You may delete all duplicates in this table. You should keep the lowest ID for each itemtype. However this is not the cause of your upgrade issue.

There is some mess in install and upgrade functions, and I'm now sure the upgrade process is running twice in some cases as yours, due to the database version not set correctly in 1.5.

I think the changes I did yesterday could fix your issue. Erase the duplicates in glpi_plugin_customfields_itemtypes, make a new backup of your database, ans try to upgrade.

micter59 commented 10 years ago

Well done ! It's ok now. I don't have much time to test now, but the installation goes well at the end. I did what you tell me : remove all duplicates in the table, and then make the process of installation again. It seems my old data are still there. Thank you a lot. Next week I'll try without the database cleaning, just to see if it's necessary to take this in account for the plugins installation.

dethegeek commented 10 years ago

Cleaning the database may help, and may be useless because you had several Version itemtypes with different values in the Enabled column. When you upgrade the plugin, the database is upgraded. A similar process of upgrade is also run when you activate the plugin, depending on the value of Version found at first. This is because mysql returns the results in an undefined order. This order may change between several identical queries.

Did you try with the changes I did this morning, or did you only reused the previous version ?

I'm waiting for your answer and the result of your next test before closing this issue.

micter59 commented 10 years ago

I did use the very last version of what you did.

I've also just done the test without cleaning the database before installing, and it fails when I want to activate the plugin. Same error : Duplicate column name 'unique' Maybe you should test this table during the process to avoid such things for the future users of the plugin ?

dethegeek commented 10 years ago

The upgrade functions appear twice : one for the upgrade when one click on the upgrade button, and an other when clicking on the activate button. I don't have access to the code right now, but I remember there are not the same checks from one to the other.

I think I shall merge them but I did not yet decided when this process should remain. I wish the upgrade execute when one click on the "upgrade" button, but I have to check the best practices to ensure the best compatibility with GLPI 0.85. There will be some changes on the plugins API.

Thanks for your heavy testings, your reports are very useful to cleanup this tricky part of the plugin.

dethegeek commented 10 years ago

Reopened while waiting for the tests of micter59.

micter59 commented 10 years ago

Perfect ! I did use the last code, without doing anything to the database, and it's ok. No problem, everything works perfectly. You can close the issue now ;-D